{"problem":{"name":"Ex - Multiply or Divide by 2","description":{"content":"You are given multisets with $N$ non-negative integers each: $A={ a_1,\\ldots,a_N }$ and $B={ b_1,\\ldots,b_N }$.   You can perform the operations below any number of times in any order. *   Choose a n","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2500,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc254_h"},"statements":[{"statement_type":"Markdown","content":"You are given multisets with $N$ non-negative integers each: $A={ a_1,\\ldots,a_N }$ and $B={ b_1,\\ldots,b_N }$.  \nYou can perform the operations below any number of times in any order.\n\n*   Choose a non-negative integer $x$ in $A$. Delete one instance of $x$ from $A$ and add one instance of $2x$ instead.\n*   Choose a non-negative integer $x$ in $A$. Delete one instance of $x$ from $A$ and add one instance of $\\left\\lfloor \\frac{x}{2} \\right\\rfloor$ instead. ($\\lfloor x \\rfloor$ is the greatest integer not exceeding $x$.)\n\nYour objective is to make $A$ and $B$ equal (as multisets).  \nDetermine whether it is achievable, and find the minimum number of operations needed to achieve it if it is achievable.\n\n## Constraints\n\n*   $1 \\leq N \\leq 10^5$\n*   $0 \\leq a_1 \\leq \\ldots \\leq a_N \\leq 10^9$\n*   $0 \\leq b_1 \\leq \\ldots \\leq b_N \\leq 10^9$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$a_1$ $\\ldots$ $a_N$\n$b_1$ $\\ldots$ $b_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc254_h","tags":[],"sample_group":[["3\n3 4 5\n2 4 6","2\n\nYou can achieve the objective in two operations as follows.\n\n*   Choose $x=3$ to delete one instance of $x\\, (=3)$ from $A$ and add one instance of $2x\\, (=6)$ instead. Now we have $A={4,5,6}$.\n*   Choose $x=5$ to delete one instance of $x\\, (=5)$ from $A$ and add one instance of $\\left\\lfloor \\frac{x}{2} \\right\\rfloor \\, (=2)$ instead. Now we have $A={2,4,6}$."],["1\n0\n1","\\-1\n\nYou cannot turn ${ 0 }$ into ${ 1 } $ ."]],"created_at":"2026-03-03 11:01:14"}}