简单的贪心
一路往后推即可;
多了往后递少了往后借;
import java.util.Scanner;
public class p1031 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int n = sc.nextInt();
int x[] = new int[n];
int m = 0; int h = 0;
int b = 0;
for (int i = 0; i < n; i++) {
x[i] = sc.nextInt();
m += x[i];
}
m = m / n; //平均值
for (int i = 0; i < n; i++) {
h += m - x[i]; //显示在该位置所处的状态
if (h != 0) { //判断其是否需要递或借
b++;
}
}
System.out.println(b);
}
}
}