QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#211942#5481. Beast Bulliesgondozu#WA 60ms9468kbC++141022b2023-10-13 00:52:452023-10-13 00:52:46

Judging History

你现在查看的是最新测评结果

  • [2023-10-13 00:52:46]
  • 评测
  • 测评结果:WA
  • 用时:60ms
  • 内存:9468kb
  • [2023-10-13 00:52:45]
  • 提交

answer

#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define Gondozu ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vpi = vector <pair<int, int>>;
using vvi = vector <vector<int>>;

const int OO = 1e9 + 5;
const int N = 2e5 + 5;

void TC()
{
    int n;
    cin >> n;
    int a[n];
    for(int& i:a) cin >> i;
    sort(a,a+n,greater<>());
    ll pref[n];
    pref[0] = a[0];
    for (int i = 1; i < n; ++i) {
        pref[i] = pref[i-1] + a[i];
    }

    int mx = 0;
    for (int i = 1; i < n; ++i) {
        int ub = upper_bound(pref+i,pref+n,pref[i-1] * 2) - pref;
        if(ub < n)
            mx = ub;
        else
            break;
    }
    cout << mx+1;
}

int32_t main() {
    Gondozu
    int t = 1;
//    cin >> t;
    while (t--) {
        TC();
        cout << '\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 60ms
memory: 9468kb

input:

500000
976631732
51389671
729809897
630844317
294721017
903231515
477913449
871071076
636104080
345822085
97441187
499323378
522845426
310022664
199310190
776622973
602672555
646874222
214723272
285341530
962727359
681361226
47426538
272153520
693133904
542337627
556307610
325596239
95738088
5495543...

output:

498939

result:

wrong answer 1st lines differ - expected: '155101', found: '498939'