Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
660 B
1
Indexable
Never
#include <iostream>
#include <algorithm>

using namespace std;
int return_answer(int* arr, int answ, int sum, int n){
	int  a = sum / n;
	for (int i = 0; i < n; i++) {
		if (arr[i] > a) {
			answ++;
		}
	}
	return answ;
}
void  check_sum() {
	cout << "-1" << endl;
}
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n, sum = 0;
		cin >> n;
		int* arr = new int[n];
		for (int i = 0; i < n; i++) {
			cin >> arr[i];
		}
		for (int i = 0; i < n; i++) {
			sum += arr[i];
		}
		if (sum % n != 0) {
			check_sum();
		}
		else {
			int answ = 0;
			answ = return_answer(arr, answ, sum, n);
			cout << answ << endl;
		}
	}
}