23072023-01-10 07:45:27gkataKövek (100 pont)cpp17Accepted 100/10027ms5304 KiB
#include <iostream>
#include <vector>;

using namespace std;

int n,i,a,s,k,l;

vector<int>x;

int main()
{
    cin>>n;
    for(i=1;i<=n;++i)
    {
        cin>>a;
        s+=a;
        x.push_back(a);
    }
    k=s/n;

    for(i=0;i<x.size();++i)
    {
        if(x[i]>k)
        {
            x[i+1]+=x[i]-k;
            x[i]-=x[i]-k;
            ++l;
        }
        else if(x[i]<k)
        {
            x[i+1]-=k-x[i];
            x[i]+=k-x[i];
            ++l;
        }
        else if(x[i]==k) continue;
    }
    cout<<l;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base100/100
1Accepted0/03ms1872 KiB
2Accepted0/027ms3252 KiB
3Accepted5/52ms2324 KiB
4Accepted5/52ms2532 KiB
5Accepted5/52ms2772 KiB
6Accepted5/52ms2880 KiB
7Accepted5/52ms3084 KiB
8Accepted5/52ms3160 KiB
9Accepted7/72ms3288 KiB
10Accepted7/72ms3416 KiB
11Accepted8/82ms3496 KiB
12Accepted8/82ms3620 KiB
13Accepted8/83ms3724 KiB
14Accepted8/84ms4156 KiB
15Accepted8/810ms4488 KiB
16Accepted8/824ms5100 KiB
17Accepted8/827ms5304 KiB