#P11371. 「CZOI-R2」糖果

「CZOI-R2」糖果

Problem Description

There are nn children in a kindergarten. Initially, the ii-th child has aia_i candies. The teacher can perform an unlimited number of operations. In each operation, she chooses one child and gives them kk 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 22 integers n,kn, k, representing the number of children and the number of candies given in each operation.

The second line contains nn integers aia_i, representing the initial number of candies of the ii-th child.

Output Format

Output YES or NO on the first line. If you output YES, then output 11 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 (20 pts20\text{ pts}): n,k103n, k \le 10^3, ai103a_i \le 10^3.
  • Subtask #2 (30 pts30\text{ pts}): k=1k = 1.
  • Subtask #3 (50 pts50\text{ pts}): no special constraints.

For 100%100\% of the testdata, 1n,k1051 \le n, k \le 10^5, 0ai23110 \le a_i \le 2^{31} - 1.

Translated by ChatGPT 5