0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 17:18:47 +00:00
OI-codes/S2OJ/1514/1514.cpp

44 lines
639 B
C++

#include <iostream>
#include <algorithm>
#include <numeric>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e6 + 5;
int n, a[N], cnt, ans;
long long sum;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
if (n == 1) {
cout << 0 << endl;
exit(0);
}
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
std::sort(a + 1, a + 1 + n);
for (int i = 1, p = 1; i <= n; i++) {
sum += a[i];
while (p <= i && a[p] <= sum / i) p++;
ans = std::max(ans, i - p + 1);
}
cout << ans << endl;
return 0;
}