QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#856601#3997. Candy MachineLightFeatherWA 0ms3712kbC++20924b2025-01-14 14:18:542025-01-14 14:18:54

Judging History

This is the latest submission verdict.

  • [2025-01-14 14:18:54]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3712kb
  • [2025-01-14 14:18:54]
  • Submitted

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: ''