QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#856601 | #3997. Candy Machine | LightFeather | WA | 0ms | 3712kb | C++20 | 924b | 2025-01-14 14:18:54 | 2025-01-14 14:18:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
typedef long long ll;
constexpr int N = 2e6;
int a[N];
void solve(){
int n;
cin >> n;
for(int i = 0; i < n; i ++)
cin >> a[i];
sort(a, a + n);
cout << endl;
int sum = 0, anss = 0, ans = 0;
for(int i = 0; i < n; i ++){
sum += a[i];
int l = 0, r = i;
while(l <= r){
int mid = l + r >> 1;
if(a[mid] * (i + 1) <= sum){
ans = max(ans, mid + 1);
l = mid + 1;
}
else
r = mid - 1;
}
// cout << ans << " ";
}
// cout << endl;
anss = n - ans;
cout << anss << endl;
}
signed main(){
cin.tie(nullptr) -> ios::sync_with_stdio(false);
int t = 1;
// cin >> t;
while(t --)
solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3712kb
input:
5 1 2 3 4 5
output:
2
result:
wrong answer 1st lines differ - expected: '2', found: ''