#P10527. [XJTUPC 2024] 最后一块石头的重量
[XJTUPC 2024] 最后一块石头的重量
Problem Description
There is a pile of stones represented by an integer array , where is the weight of the -th stone.
In each round, choose any two stones and smash them together. Suppose their weights are and , with . Then the possible results are:
- If , then both stones will be completely smashed.
- If , then the stone of weight will be completely smashed, and the stone of weight will have a new weight of .
In the end, at most one stone will remain. Output the minimum possible weight of this stone. If no stone remains, output .
Input Format
The input has two lines.
The first line contains an integer (), representing the number of stones.
The second line contains integers (), representing the weight of the -th stone.
Output Format
The output has one line.
Output one integer representing the answer.
6
2 7 4 1 8 1
1
5
31 26 33 21 40
5
Hint
Translated by ChatGPT 5