#P7535. [COCI 2016/2017 #4] Kas
[COCI 2016/2017 #4] Kas
Problem Description
Kile and Pogi found banknotes on the road. Each of them will take some banknotes so that the total amount each person gets is the same. At the same time, they want this total amount to be as large as possible.
Next, they will take the remaining banknotes to a casino. Because they are very lucky, after using the remaining amount as a bet, they will get double that amount. Then, they will split the obtained money equally again and add it to each person’s total amount.
Find the total amount of money each person can get.
Input Format
The first line contains an integer .
The next lines each contain a positive integer , representing the value of the -th banknote. It is guaranteed that the total value of all banknotes does not exceed .
Output Format
Output the total amount of money each person can get.
4
2
3
1
6
6
5
2
3
5
8
13
18
Hint
[Sample 1 Explanation]
Kile can choose the banknotes with values , and Pogi can choose the banknote with value . Since there are no remaining banknotes, the total amount each person gets is .
[Sample 2 Explanation]
Kile can choose the banknotes with values , and Pogi can choose the banknote with value . The remaining banknotes have values , so after going to the casino, the total amount each person gets is .
[Constraints]
For of the testdata, .
For of the testdata, , .
For of the testdata, .
[Notes and Explanation]
This problem is translated from COCI 2016-2017 CONTEST #4 T3 Kas.
The score of this problem follows the original COCI settings, with a full score of .
Translated by ChatGPT 5