#P9636. 「yyOI R1」youyou 的篡改(Easy Ver.)
「yyOI R1」youyou 的篡改(Easy Ver.)
Background
The Easy Version and the Hard Version differ only in the final required output; all other descriptions are identical.
Problem Description
youyou is going to hold a contest. There are problems in this contest, and each problem has a difficulty value .
youyou gives a counting parameter . He believes that the solvability of problem should be the sum of the difficulty values of the hardest problems among problems , after sorting their difficulty values in nondecreasing order.
Since problems are too easy, youyou does not want to consider the solvability of these problems.
So the total solvability of this contest is the sum of the solvability from problem to problem , i.e., the value of .
youyou can tamper with the difficulty of problem to any positive integer, but he does not want this contest to be too hard or too easy, so he requires that the total solvability must be within .
youyou wants to know: by tampering with the difficulty of problem , what is the maximum value the total solvability can be changed to?
In particular, if no solution exists, output .
Input Format
The first line contains five positive integers: .
The second line contains integers, where the -th number is the difficulty value of problem .
Output Format
Output one number in a single line, representing the maximum total solvability that can be achieved under the constraints.
5 1 1 5 10
1 2 2 2 2
10
Hint
Sample Explanation #1
Since , can be tampered with. When , the total solvability is . Since , the maximum total solvability can be tampered to .
Constraints
This problem uses Subtasks. For each Subtask, you must pass all test points to get the score for that part.
| Subtask ID | Score | |
|---|---|---|
For of the data, , , .
Translated by ChatGPT 5