#C810. Equalize Villager Coins
Equalize Villager Coins
Equalize Villager Coins
You are given n villagers where the i-th villager possesses a certain number of coins. Your task is to determine whether it is possible to equalize the number of coins held by each villager by transferring coins from villagers with surplus coins to those with fewer coins.
The target number for coins each villager must have is calculated as \( \text{target} = \frac{\text{total coins}}{n} \). Note that if the total sum of coins is not divisible by \( n \), then it is impossible to equalize the coins.
If equalization is possible, count the minimum number of operations required, where each operation moves a single coin from a villager who has more than the target to a villager who has less.
inputFormat
The input is given in two lines from stdin:
- The first line contains a single integer \( n \), representing the number of villagers.
- The second line contains \( n \) space-separated integers \( c_1, c_2, \ldots, c_n \), where each \( c_i \) is the number of coins the \( i\)-th villager initially has.
outputFormat
Output to stdout a single line. If it is possible to equalize the coins, print "YES" followed by a space and the minimum number of operations required. Otherwise, print "NO".
## sample3
3 1 2
YES 1
</p>