40422023-03-09 17:25:56BalintGezaKövek (100 pont)cpp11Accepted 100/10027ms4876 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int kupac, ossz=0, j=0;
    cin>>kupac;
    vector<int>matrix(kupac);
    int i;
    for(i=0;i<kupac;i++)
    {
        cin>>matrix.at(i);
        ossz+=matrix.at(i);
    }
    int cel=ossz/kupac;
    for(i=0;i<kupac;i++)
    {
        if(matrix[i]<cel)
        {
            matrix[i+1]=matrix[i+1]-(cel-matrix[i]);
            matrix[i]=cel;
            j++;
        }
        else if(matrix[i]>cel)
        {
            matrix[i+1]=matrix[i+1]+(matrix[i]-cel);
            matrix[i]=cel;
            j++;
        }

    }
    cout<<j<<endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base100/100
1Accepted0/03ms1996 KiB
2Accepted0/027ms2936 KiB
3Accepted5/53ms2372 KiB
4Accepted5/53ms2404 KiB
5Accepted5/53ms2656 KiB
6Accepted5/53ms2832 KiB
7Accepted5/53ms3188 KiB
8Accepted5/53ms3340 KiB
9Accepted7/73ms3404 KiB
10Accepted7/73ms3580 KiB
11Accepted8/83ms3600 KiB
12Accepted8/83ms3584 KiB
13Accepted8/83ms3704 KiB
14Accepted8/84ms3944 KiB
15Accepted8/810ms4064 KiB
16Accepted8/824ms4436 KiB
17Accepted8/827ms4876 KiB