#P11371. 「CZOI-R2」糖果
「CZOI-R2」糖果
Problem Description
There are children in a kindergarten. Initially, the -th child has candies. The teacher can perform an unlimited number of operations. In each operation, she chooses one child and gives them candies.
To prevent children from getting angry and eating other children's candies, the teacher wants all children to have the same number of candies. If the goal can be achieved, output YES and the minimum number of operations. If it cannot be achieved, output NO directly.
Input Format
The first line contains integers , representing the number of children and the number of candies given in each operation.
The second line contains integers , representing the initial number of candies of the -th child.
Output Format
Output YES or NO on the first line. If you output YES, then output integer on the next line, representing the answer.
6 3
1 1 4 5 1 4
NO
3 2
9 1 5
YES 6
Hint
Constraints
This problem uses bundled testdata.
- Subtask #1 (): , .
- Subtask #2 (): .
- Subtask #3 (): no special constraints.
For of the testdata, , .
Translated by ChatGPT 5