#P6568. [NOI Online #3 提高组] 水壶
[NOI Online #3 提高组] 水壶
Problem Description
There are water jugs with infinite capacity, numbered from to . Initially, jug contains units of water.
You can perform at most operations. In each operation, you need to choose an index such that , and then pour all the water from jug into jug .
In the end, you may choose exactly one jug and drink all the water in it. Now, please find the maximum number of units of water you can drink.
Input Format
The first line contains a positive integer , indicating the number of water jugs.
The second line contains a non-negative integer , indicating the upper limit on the number of operations.
The third line contains non-negative integers, separated by spaces, representing the initial amounts of water , , , .
Output Format
One line with a single non-negative integer, indicating the answer.
10
5
890 965 256 419 296 987 45 676 976 742
3813
Hint
Constraints
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that , , and .
Translated by ChatGPT 5