标签:
时间限制: 1 Sec 内存限制: 128 MB
提交: 46 解决: 27
[提交][状态]
The first line contains integer n (1 ≤ n ≤ 105) — the array size. The second line contains space-separated integers a1, a2, ..., an (ai ≤ 100000) — the original array.
Print a single integer — the maximum number of equal array elements Radical can get if he performs an arbitrary number of the given operation.
2
2 3
3
2 4 3
1 3
经过任意次,在数组里任意取数,一个数相加,一个数相减后,最多可以得到几个相等的数
先求出平均值想必是极好哒。我们当然想尽量把所有数都凑成平均值,如果一定会有的数凑不成,那这些数就可以让我们随意拿来减或者加,以便让其他数减或加凑成平均值。而这些数之和与平均值的余数
#include<iostream> #include<cstdio> #include<cstring> using namespace std; #define N 100005 int main() { int n, a[N], sum; while(cin >> n) { memset(a, 0, sizeof(a)); sum = 0; for(int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } int x = sum / n; int y = sum % n; if(y == 0) printf("%d\n", n); else{ printf("%d\n", n-1-y/(x+1)); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/Tinamei/p/4689691.html