29062023-02-02 13:29:17KristófKövek (100 pont)cpp11Accepted 100/10027ms4196 KiB
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;

    int szamok[n];

    int sum=0;

    for(int i=0;i<n;i++){
        cin>>szamok[i];
        sum = sum+szamok[i];
    }
    int atlag = sum/n;
    int drab=0;
    for(int i=0;i<n;i++){
        if(szamok[i]<atlag){
            szamok[i+1] -= atlag-szamok[i];
            szamok[i] +=atlag-szamok[i];
            drab++;
        }
        else if(szamok[i]>atlag){
                szamok[i+1]+=szamok[i]-atlag;
            szamok[i] -= szamok[i]-atlag;

            drab++;
        }

    }

    cout<<drab;


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base100/100
1Accepted0/03ms1876 KiB
2Accepted0/027ms2892 KiB
3Accepted5/53ms2332 KiB
4Accepted5/52ms2416 KiB
5Accepted5/53ms2488 KiB
6Accepted5/53ms2704 KiB
7Accepted5/52ms2784 KiB
8Accepted5/53ms2916 KiB
9Accepted7/72ms3036 KiB
10Accepted7/73ms3000 KiB
11Accepted8/83ms3004 KiB
12Accepted8/83ms3000 KiB
13Accepted8/83ms3160 KiB
14Accepted8/84ms3324 KiB
15Accepted8/810ms3484 KiB
16Accepted8/824ms4100 KiB
17Accepted8/827ms4196 KiB