#P1109. 学生分组
学生分组
Description
There are groups of students. You are given the initial number of students in each group, and the upper bound and lower bound for each group size (with ). In one operation, you may select one student from a group and move them to another group. What is the minimum number of operations required to make the sizes of all groups fall within ?
Input Format
The first line contains an integer , the number of student groups. The second line contains integers, the number of students in each group. The third line contains two integers , the lower and upper bounds.
Output Format
Output a single integer, the minimum number of moves. If it is impossible to satisfy the condition, output -1.
2
10 20
10 15
5
Hint
Constraints
For all testdata, it is guaranteed that .
Translated by ChatGPT 5
京公网安备 11011102002149号