QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#240024#5481. Beast Bullieskareemsakkary#WA 57ms5144kbC++141.6kb2023-11-05 08:32:192023-11-05 08:32:19

Judging History

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

  • [2023-11-05 08:32:19]
  • 评测
  • 测评结果:WA
  • 用时:57ms
  • 内存:5144kb
  • [2023-11-05 08:32:19]
  • 提交

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));
    ll mx = arr.back();
    ll sum = 0;
    ll ans = 1;
    int s = n-2;
    for(int i = n-2 ; i>=0 ;i--){
        sum += arr[i];
        if(sum >= mx) {
            ans +=  (s - i + 1);
            mx += sum;
            sum = 0;
            s = i;
        }
    }
    cout << ans <<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: 57ms
memory: 5144kb

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:

155116

result:

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