25212023-01-15 18:17:39szabosamuelKövek (100 pont)cpp11Accepted 100/10026ms4668 KiB
#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int k[n+1];
    for(int i=1; i<=n; i++)
    {
        cin >> k[i];
    }
    int sum=0;
    for(int i=1; i<=n; i++)
    {
        sum+=k[i];
    }
    sum=sum/n;
    int sz=0;
    for(int i=1; i<n; i++)
    {
        if(k[i]>sum)
        {
             k[i+1]+=(k[i]-sum);
            k[i]-=(k[i]-sum);
            sz++;
        }
        else if(k[i]<sum)
        {
            k[i+1]-=(sum-k[i]);
            k[i]+=(sum-k[i]);
            sz++;
        }
    }
    cout << sz;


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base100/100
1Accepted0/03ms1876 KiB
2Accepted0/026ms2904 KiB
3Accepted5/52ms2324 KiB
4Accepted5/52ms2532 KiB
5Accepted5/52ms2732 KiB
6Accepted5/52ms3000 KiB
7Accepted5/52ms3084 KiB
8Accepted5/52ms3304 KiB
9Accepted7/72ms3336 KiB
10Accepted7/72ms3268 KiB
11Accepted8/82ms3392 KiB
12Accepted8/82ms3336 KiB
13Accepted8/83ms3468 KiB
14Accepted8/84ms3852 KiB
15Accepted8/810ms4128 KiB
16Accepted8/823ms4452 KiB
17Accepted8/826ms4668 KiB