#include < iostream > #include < cstdio > #include < algorithm > using namespace std;
int N;
int a[105];
int main() {
cin >> N;
int tot = 0;
for (int i = 1; i <= N; i++) {
scanf("%d", &a[i]);
tot += a[i];
}
tot /= N;
for (int i = 1; i <= N; i++) a[i] = tot - a[i];
int j = 1,
t = N,
cnt = 0;
while (!a[j]) j++;
while (!a[t]) t--;
for (int i = j; i < t; i++) {
while (!a[i]) i++;
//cout<<i<<" "<<a[i]<<" "<<cnt<<endl;
a[i + 1] += a[i];
a[i] = 0;
cnt++;
}
cout << cnt << endl;
}
来源: http://www.bubuko.com/infodetail-2283480.html