#C8614. Equalize Array Elements

    ID: 52616 Type: Default 1000ms 256MiB

Equalize Array Elements

Equalize Array Elements

Given an array of integers, determine whether it is possible to make all its elements equal under a specific condition.

You are given two integers \(n\) and \(m\) and an array \(A\) of \(n\) integers. Let \(S = \sum_{i=1}^{n} A_i\). It is possible to make all elements equal if and only if:

\[ \text{(i)}\quad S \mod n = 0 \quad \text{and} \quad \text{(ii)}\quad \frac{S}{n} \le m \]

If both conditions hold, output "YES", otherwise output "NO".

inputFormat

The first line contains two integers, (n) and (m), separated by a space. The second line contains (n) space-separated integers representing the array elements.

outputFormat

Output a single line with either "YES" if it is possible to equalize the array elements under the given constraints, or "NO" otherwise.## sample

3 5
1 2 3
YES