{"problem":{"name":"Penguin Skating","description":{"content":"There are $L$ squares lining up horizontally in a row, numbered $1, 2, \\ldots, L$ from left to right. On those squares are $N$ penguins, numbered $1, 2, \\ldots, N$ from left to right. Initially, Pengu","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc048_c"},"statements":[{"statement_type":"Markdown","content":"There are $L$ squares lining up horizontally in a row, numbered $1, 2, \\ldots, L$ from left to right.\nOn those squares are $N$ penguins, numbered $1, 2, \\ldots, N$ from left to right. Initially, Penguin $i$ is on Square $A_i$. Here, $1 \\leq A_1 < A_2 < \\ldots < A_N \\leq L$ holds.\nYou can do the following operations any number of times:\n\n*   Choose one penguin and slide it to the left or the right. The penguin will keep sliding as long as there is an empty square ahead. It will stop when it reaches a square just before a square occupied by another penguin, or there is no square ahead.\n\nFor example, assume that $N=3$, $L=10$, and the penguins are on the squares $(2,3,7)$. Here, if we slide Penguin $2$ to the right, it will move to Square $6$; if we slide Penguin $3$ to the right, it will move to Square $10$.\nYour objective is to put Penguin $i$ on Square $B_i$ for every $i$. Here, $1 \\leq B_1 < B_2 < \\ldots < B_N \\leq L$ holds. Determine whether the objective is achievable. If it is achievable, find the minimum number of operations needed.\n\n## Constraints\n\n*   $1 \\leq N \\leq 10^5$\n*   $N \\leq L \\leq 10^9$\n*   $1 \\leq A_1 < A_2 < \\ldots < A_N \\leq L$\n*   $1 \\leq B_1 < B_2 < \\ldots < B_N \\leq L$\n*   All numbers in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $L$\n$A_1$ $A_2$ $\\cdots$ $A_N$\n$B_1$ $B_2$ $\\cdots$ $B_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc048_c","tags":[],"sample_group":[["4 11\n3 4 6 10\n1 5 6 11","3\n\nThe following sequence of operations achieves the objective:\n\n*   Slide Penguin $1$ to the left. The penguins are now on the squares $(1,4,6,10)$.\n*   Slide Penguin $2$ to the right. The penguins are now on the squares $(1,5,6,10)$.\n*   Slide Penguin $4$ to the right. The penguins are now on the squares $(1,5,6,11)$."],["1 3\n1\n2","\\-1"],["10 1000000000\n65110170 68805223 123016442 275946481 661490312 760727752 764540566 929355340 930658577 947099792\n1 2 123016442 661490311 929355337 930658574 999999997 999999998 999999999 1000000000","13"]],"created_at":"2026-03-03 11:01:14"}}