{"problem":{"name":"[ICPC 2024 Xi'an I] Make Them Straight","description":{"content":"There is a sequence $a$ of non-negative integers of length $n$, the $i$-th element of it is $a_i(1\\leq i\\leq n)$. A sequence is defined as 'good' if and only if there exists a non negative integer $k","description_type":"Markdown"},"platform":"Luogu","limit":{"time_limit":2000,"memory_limit":524288},"difficulty":{"LuoguStyle":"P4"},"is_remote":true,"is_sync":true,"sync_url":null,"sign":"LGP10556"},"statements":[{"statement_type":"Markdown","content":"There is a sequence $a$ of non-negative integers of length $n$, the $i$-th element of it is $a_i(1\\leq i\\leq n)$.\n\nA sequence is defined as 'good' if and only if there exists a non negative integer $k(0\\leq k\\leq 10^6)$ that satisfies the following condition:\n\n$a_{i}=a_{1}+(i-1)k$ for all $1\\leq i\\leq n$.\n\nTo make this sequence 'good', for each $i(1\\leq i\\leq n)$, you can do nothing, or pay $b_i$ coin to replace $a_i$ with any non-negative integer.\n\nThe question is, what is the minimum cost to make this sequence 'good'.\n\n## Input\n\nThe first line contains an integer $n(1\\leq n\\leq 2\\times 10^5)$, described in the statement.\n\nThe second line contains $n$ integers $a_1,...,a_n(0\\leq a_i\\leq 10^6)$.\n\nThe third line contains $n$ integers $b_1,...,b_n(0\\leq b_i\\leq 10^6)$.\n\n## Output\n\nOne integer, the answer.\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"LGP10556","tags":["2024","O2优化","枚举","ICPC","调和级数","西安"],"sample_group":[["5\n1 4 3 2 5\n1 1 1 1 1","2"],["5\n1 4 3 2 5\n1 9 1 1 1","3"]],"created_at":"2026-03-03 11:09:25"}}