50002023-04-08 17:27:00Laci3000Kövek (100 pont)cpp17Accepted 100/10026ms4360 KiB

#include <vector>
#include <iostream>

using namespace std;

int beolvasas(){
	int kupacok;
	cin >> kupacok;
	vector<int>lista(kupacok);
	int kovek_szama = 0;
	for (int i = 0; i < kupacok; i++)
	{
		cin >> lista[i];
		kovek_szama += lista[i];
	}


	
	int celertek = kovek_szama / kupacok;
	
	int kulonbseg = 0;
	int a = 0;
	for (int i = 1; i < kupacok; i++)
	{
		if (lista[i - 1] != celertek) {
			kulonbseg = lista[i - 1] - celertek;
			
			lista[i - 1] -= kulonbseg;
			lista[i] += kulonbseg;
			a++;
		}
		
	}
	return a;
}

int main()
{
	cout << beolvasas();
}

SubtaskSumTestVerdictTimeMemory
base100/100
1Accepted0/03ms1720 KiB
2Accepted0/026ms2668 KiB
3Accepted5/53ms2076 KiB
4Accepted5/52ms2144 KiB
5Accepted5/52ms2148 KiB
6Accepted5/53ms2384 KiB
7Accepted5/53ms2480 KiB
8Accepted5/53ms2728 KiB
9Accepted7/72ms2820 KiB
10Accepted7/72ms2772 KiB
11Accepted8/83ms2896 KiB
12Accepted8/83ms3112 KiB
13Accepted8/83ms3332 KiB
14Accepted8/84ms3444 KiB
15Accepted8/810ms3744 KiB
16Accepted8/824ms3840 KiB
17Accepted8/826ms4360 KiB