#P5804. [SEERC 2019] Absolute Game
[SEERC 2019] Absolute Game
Description
Alice and Bob are playing a game. Alice has a sequence containing integers, and Bob has a sequence containing integers. In each round, the player must delete one number from their own sequence. The players take turns, and Alice moves first.
When both sequences have only one number left, the game ends. Let the remaining number in Alice’s sequence be , and the remaining number in Bob’s sequence be . Alice wants to maximize the absolute value of the difference between and , while Bob wants to minimize this value. Both players play optimally.
Compute the result when the game ends.
Input Format
The first line contains an integer , representing the number of integers in each sequence.
The second line contains integers , representing the numbers in Alice’s sequence.
The third line contains integers , representing the numbers in Bob’s sequence.
Output Format
Output the absolute value of the difference between and when both players play optimally.
4
2 14 7 14
5 10 9 22
4
1
14
42
28
Hint
In the first sample, and , so the difference between the two numbers is .
In the second sample, both sequences already have only one number left, so and .
Translated by ChatGPT 5
京公网安备 11011102002149号