#P2780. [AHOI2016初中组] 游戏
[AHOI2016初中组] 游戏
Description
Xiao Xue and Xiao Keke are playing a number game. They have prepared cards, each with an integer on it. At the beginning, Xiao Xue chooses an integer with and tells Xiao Keke the value of . Then Xiao Keke selects exactly cards and sums their numbers; denote this sum by .
Xiao Xue wants the absolute difference between and to be as large as possible, while Xiao Keke wants it to be as small as possible. Before the game starts, both of them know , , , and , and also the number on every card. After Xiao Xue decides , it cannot be changed, and only then does Xiao Keke select the cards.
Xiao Xue wants to know, under optimal play by both of them, how large the absolute difference between and can be.
Input Format
The input has two lines.
The first line contains 4 integers , , , and , satisfying and .
The second line contains integers, namely to , which are the numbers on the cards.
Each number satisfies .
Output Format
Output one line with a single integer, which is the maximum possible value of the absolute difference between and .
4 2 58 100
10 10 50 80
15
8 3 1300 1800
2 0 1 9 1 4 0 5
1782
Hint
For 30% of the testdata, and .
For 80% of the testdata, and .
For 100% of the testdata, and .
Translated by ChatGPT 5
京公网安备 11011102002149号