119462024-11-21 18:57:18tomi7Kövek (100 pont)cpp17Accepted 100/10030ms764 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;cin>>n;
	vector<int> a(n);
	int osszeg=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		osszeg+=a[i];
	}
	if(osszeg%n!=0){
		cout<<-1<<'\n';
		return 0;
	}
	int abcd=osszeg/n;
	int kkk=0;
	int ans=0;
	int aaabbb=0;
	cerr<<abcd;
	for(int i=0;i<n;i++){
		kkk+=a[i];
		aaabbb++;
		if(kkk==abcd*(aaabbb)){
			kkk=0;
			ans++;
			cerr<<"\nItt vagyok\n";
			aaabbb=0;
		}
	}
	cout<<n-ans<<'\n';
}
SubtaskSumTestVerdictTimeMemory
base100/100
1Accepted0/01ms320 KiB
2Accepted0/030ms568 KiB
3Accepted5/51ms320 KiB
4Accepted5/51ms508 KiB
5Accepted5/51ms320 KiB
6Accepted5/51ms320 KiB
7Accepted5/51ms320 KiB
8Accepted5/51ms320 KiB
9Accepted7/71ms320 KiB
10Accepted7/71ms320 KiB
11Accepted8/81ms320 KiB
12Accepted8/81ms320 KiB
13Accepted8/82ms500 KiB
14Accepted8/84ms508 KiB
15Accepted8/810ms564 KiB
16Accepted8/827ms764 KiB
17Accepted8/829ms568 KiB