49942023-04-08 16:26:14Laci3000Kövek (100 pont)cpp11Wrong answer 27/10027ms4160 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 - 1; i++)
	{
		if (lista[i - 1] != celertek) {
			kulonbseg = lista[i] - (celertek - lista[i - 1]);

			lista[i - 1] += kulonbseg;
			lista[i] -= kulonbseg;
			a++;
		}
		else if (lista[i] != celertek) {
			kulonbseg = lista[i] - celertek;
			lista[i] -= kulonbseg;
			lista[i + 1] += kulonbseg;
			a++;
		}
	}
	return a;
}

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

SubtaskSumTestVerdictTimeMemory
base27/100
1Accepted0/03ms1816 KiB
2Wrong answer0/027ms2768 KiB
3Accepted5/53ms2364 KiB
4Wrong answer0/53ms2480 KiB
5Wrong answer0/53ms2716 KiB
6Wrong answer0/53ms2664 KiB
7Wrong answer0/52ms2668 KiB
8Wrong answer0/53ms2788 KiB
9Accepted7/72ms2912 KiB
10Accepted7/73ms3068 KiB
11Wrong answer0/83ms3280 KiB
12Wrong answer0/83ms3368 KiB
13Wrong answer0/83ms3360 KiB
14Wrong answer0/84ms3392 KiB
15Accepted8/810ms3424 KiB
16Wrong answer0/824ms3896 KiB
17Wrong answer0/827ms4160 KiB