32 lines
535 B
C++
32 lines
535 B
C++
|
#include <ios>
|
||
|
#include<iostream>
|
||
|
|
||
|
int n;
|
||
|
int a[(int)1e4+5];
|
||
|
|
||
|
int main(){
|
||
|
std::ios::sync_with_stdio(false),std::cin.tie(nullptr),std::cout.tie(nullptr);
|
||
|
|
||
|
std::cin>>n;
|
||
|
|
||
|
int sum=0;
|
||
|
for(int i=1;i<=n;i++){
|
||
|
std::cin>>a[i];
|
||
|
sum+=a[i];
|
||
|
}
|
||
|
|
||
|
int avg = sum/n;
|
||
|
|
||
|
int ans = 0;
|
||
|
for(int i=1;i<n;i++){
|
||
|
ans++;
|
||
|
if(a[i]>avg){
|
||
|
a[i+1]+=a[i]-avg;
|
||
|
}else if(a[i]<avg){
|
||
|
a[i+1]-=avg-a[i];
|
||
|
}else{
|
||
|
ans--;
|
||
|
}
|
||
|
}
|
||
|
std::cout<<ans<<"\n";
|
||
|
}
|