QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#856590#3997. Candy MachineLightFeatherWA 0ms3584kbC++20818b2025-01-14 14:04:172025-01-14 14:04:18

Judging History

This is the latest submission verdict.

  • [2025-01-14 14:04:18]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3584kb
  • [2025-01-14 14:04:17]
  • 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);
    int sum = 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 << endl;
}

signed main(){
    cin.tie(nullptr) -> ios::sync_with_stdio(false);
    int t = 1;
    // cin >> t;
    while(t --)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

input:

5
1 2 3 4 5

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3584kb

input:

18
3 5 5 1 2 2 3 9 2 2 7 1 7 3 2 3 6 6

output:

11

result:

wrong answer 1st lines differ - expected: '7', found: '11'