40402023-03-09 17:07:50KicsenKövek (100 pont)cpp17Accepted 100/10027ms4912 KiB
#include <iostream>

using namespace std;

int main()
{
    int n,atl=0,mozg=0;
    cin>>n;
    int a[n],i=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        atl+=a[i];
    }
    atl=atl/n;
    for(i=0;i<n;i++)
    if(a[i]>atl)
    {
        a[i+1]+=a[i]-atl;
        a[i]=atl;
        mozg++;
    }
    else if (a[i]<atl)
    {
        a[i+1]-=(atl-a[i]);
        a[i]=atl;
        mozg++;
    }
    cout<<mozg;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base100/100
1Accepted0/03ms1876 KiB
2Accepted0/027ms2892 KiB
3Accepted5/53ms2360 KiB
4Accepted5/52ms2568 KiB
5Accepted5/53ms2852 KiB
6Accepted5/52ms2952 KiB
7Accepted5/52ms3072 KiB
8Accepted5/53ms3104 KiB
9Accepted7/73ms3300 KiB
10Accepted7/73ms3508 KiB
11Accepted8/83ms3660 KiB
12Accepted8/83ms3820 KiB
13Accepted8/83ms3820 KiB
14Accepted8/84ms3948 KiB
15Accepted8/810ms4096 KiB
16Accepted8/824ms4792 KiB
17Accepted8/827ms4912 KiB