17242022-12-01 19:31:13sarminKövek (100 pont)cpp17Runtime error 0/1003ms3960 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {

	int N;
	cin >> N;
	vector<int> K;
	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 = 0; i < N-1; i++) {
		if (K[i] == allWill || K[i+1] == allWill) continue;
		if (K[i] <= K[i+1] && K[i] != allWill) {
			K[i+1] -= allWill-K[i];
			K[i] = allWill;
		} else {
			K[i+1] += K[i]-allWill;
			K[i] = allWill;
		}
		valami++;
	}
	cout << valami;

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/100
1Runtime error0/03ms1848 KiB
2Runtime error0/02ms2104 KiB
3Runtime error0/52ms2284 KiB
4Runtime error0/52ms2564 KiB
5Runtime error0/52ms2768 KiB
6Runtime error0/52ms2700 KiB
7Runtime error0/52ms2980 KiB
8Runtime error0/52ms3260 KiB
9Runtime error0/72ms3464 KiB
10Runtime error0/72ms3588 KiB
11Runtime error0/82ms3756 KiB
12Runtime error0/82ms3960 KiB
13Runtime error0/82ms3876 KiB
14Runtime error0/82ms3776 KiB
15Runtime error0/82ms3796 KiB
16Runtime error0/82ms3800 KiB
17Runtime error0/82ms3772 KiB