提交时间:2023-11-02 13:35:19

运行 ID: 108359

//I am Block Xuan #include<bits/stdc++.h> //I am Block Xuan using namespace std; //I am Block Xuan int a[114],cnt; //I am Block Xuan int main(){ //I am Block Xuan int n,sum = 0; //I am Block Xuan cin>>n; //I am Block Xuan for (int i = 1;i <= n;i++){ //I am Block Xuan cin>>a[i]; //I am Block Xuan sum += a[i]; //I am Block Xuan } //I am Block Xuan sum /= n; //I am Block Xuan for (int i = 1;i < n;i++){ //I am Block Xuan if (a[i] < sum){ //I am Block Xuan a[i + 1] -= (sum - a[i]); //I am Block Xuan a[i] = sum; //I am Block Xuan cnt++; //I am Block Xuan } //I am Block Xuan else if (a[i] > sum){ //I am Block Xuan a[i + 1] += a[i] - sum; //I am Block Xuan a[i] = sum; //I am Block Xuan cnt++; //I am Block Xuan } //I am Block Xuan } //I am Block Xuan cout<<cnt; //I am Block Xuan return 0; //I am Block Xuan } //I am Block Xuan