16152022-11-29 15:34:39sarminKövek (100 pont)cpp17Wrong answer 5/10026ms4616 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {

	int N;
	cin >> N;
	vector<int> K(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> K[i];
		sum += K[i];
	}

	int allWill = sum / N, valami = 0;
	for (int i = 1; i < N; i++) {
		valami += K[i-1] - allWill;
		if (abs(K[i]-allWill) < abs(K[i-1]-allWill)) {
			K[i] -= K[i-1] - allWill;
		} else {
			K[i] += K[i-1] - allWill;
		}
		K[i-1] = allWill;
	}
	cout << valami;

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base5/100
1Accepted0/03ms1816 KiB
2Wrong answer0/026ms2708 KiB
3Accepted5/52ms2208 KiB
4Wrong answer0/52ms2452 KiB
5Wrong answer0/52ms2616 KiB
6Wrong answer0/52ms2864 KiB
7Wrong answer0/52ms2936 KiB
8Wrong answer0/52ms2900 KiB
9Wrong answer0/72ms3144 KiB
10Wrong answer0/72ms3096 KiB
11Wrong answer0/82ms3228 KiB
12Wrong answer0/82ms3300 KiB
13Wrong answer0/83ms3468 KiB
14Wrong answer0/84ms3480 KiB
15Wrong answer0/89ms3692 KiB
16Wrong answer0/823ms4076 KiB
17Wrong answer0/826ms4616 KiB