#P7622. [AHOI2021初中组] 坑
[AHOI2021初中组] 坑
Description
The game is played on a number line that extends infinitely to the left and right. There are fleas and pits on it, and they can both be modeled as points on the number line.
In each round, the player must choose to make all fleas jump together one unit to the left or one unit to the right. If a point representing a flea coincides with a point representing a pit, the flea will fall into the pit, scream, and then die.
The upset Xiaoxue wants to kill all fleas in the shortest time. Please help her compute the minimum number of rounds needed.
Input Format
The first line contains two positive integers separated by spaces.
The second line contains integers separated by spaces, where is the initial coordinate of the -th flea.
The third line contains integers separated by spaces, where is the coordinate of the -th pit.
The input guarantees that all of these coordinates are pairwise distinct.
Output Format
Only one line with one integer, the minimum number of rounds needed to kill all fleas.
3 2
3 -1 2
0 10
5
见附加文件的 hole2.in。
见附加文件的 hole2.ans。
Hint
[Sample 1 Explanation]
In the first round, make all fleas jump one step to the right. The second flea falls into the first pit, and the remaining two fleas are at respectively.
In the next four rounds, make all fleas jump to the left. Both fleas fall into the first pit, and the game ends.
[Constraints and Notes]
Note: The input size of this problem is large, so please avoid overly slow input methods.
- For of the testdata, , .
- For another of the testdata, .
- For another of the testdata, .
- For another of the testdata, .
- For another of the testdata, .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号