QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#240014#5481. Beast Bullieskareemsakkary#WA 61ms5168kbC++141.5kb2023-11-05 07:26:472023-11-05 07:26:48

Judging History

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

  • [2023-11-05 07:26:48]
  • 评测
  • 测评结果:WA
  • 用时:61ms
  • 内存:5168kb
  • [2023-11-05 07:26:47]
  • 提交

answer

#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define fr(n) for(ll i = 0 ; i < n ; i++)
#define frj(n) for(ll j = 0 ; j < n ; j++)
#define ll long long
#define files    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define Ksakkary ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll mod = 1e9 + 7;

using namespace std;


ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll mult(ll a, ll b) {
    return ((a % mod) * (b % mod)) % mod;
}

ll add(ll a, ll b) {
    return ((a % mod) + (b % mod)) % mod;
}

ll subtract(ll a, ll b) {
    return ((a % mod) - (b % mod) + (2 * mod)) % mod;
}

const unsigned ll N = 2e6 + 5;

int knightX[] = {-2, -2, 2, 2, 1, 1, -1, -1};
int knighty[] = {-1, 1, -1, 1, -2, 2, -2, 2};

int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};
char di[] = {'D', 'L', 'U', 'R'};


void solve() {
    int n ; cin >> n;
    vector<int> arr(n);
    fr(n){
        cin >> arr[i];
    }
    sort(all(arr));
    int mx = arr.back();
    ll sum = 0;
    for(int i = n-2 ; i>=0 ;i--){
        sum += arr[i];
        if(sum >= mx) {
            cout << 1 + (n - 2 - i + 1);
            return;
        }
    }
    cout << 1 <<endl;
}

int main() {
    Ksakkary
#ifndef ONLINE_JUDGE
    files
#endif
    // sieve();
    ll t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 61ms
memory: 5168kb

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:

3

result:

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