提交时间:2023-11-01 13:41:45
运行 ID: 108237
#include<bits/stdc++.h> using namespace std; int a[114],cnt; int main(){ int n,sum = 0; cin>>n; for (int i = 1;i <= n;i++){ cin>>a[i]; sum += a[i]; } sum /= n; for (int i = 1;i < n;i++){ if (a[i] < sum){ a[i + 1] -= (sum - a[i]); a[i] = sum; cnt++; } else if (a[i] > sum){ a[i + 1] += a[i] - sum; a[i] = sum; cnt++; } } cout<<cnt; return 0; }