Submission #991918

# Submission time Handle Problem Language Result Execution time Memory
991918 2024-06-03T11:59:28 Z toast12 Gym Badges (NOI22_gymbadges) C++14
9 / 100
262 ms 14020 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

int main() {
    int n;
    cin >> n;
    vector<pair<ll, ll>> gyms(n);
    for (int i = 0; i < n; i++) {
        cin >> gyms[i].second;
    }
    for (int i = 0; i < n; i++) {
        cin >> gyms[i].first;
    }
    sort(gyms.begin(), gyms.end());
    ll level = 0;
    ll ans = 0;
    priority_queue<ll> pq;
    for (int i = 0; i < n; i++) {
        if (level <= gyms[i].first) {
            level += gyms[i].second;
            pq.push(gyms[i].second);
            ans++;
        }
        else {
            ll x = pq.top();
            if (level-x <= gyms[i].first && x >= gyms[i].second) {
                pq.pop();
                pq.push(gyms[i].second);
                level -= x;
                level += gyms[i].second;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 255 ms 8024 KB Output is correct
2 Correct 257 ms 8272 KB Output is correct
3 Correct 262 ms 8260 KB Output is correct
4 Correct 251 ms 8272 KB Output is correct
5 Correct 254 ms 8252 KB Output is correct
6 Correct 222 ms 8532 KB Output is correct
7 Correct 238 ms 8240 KB Output is correct
8 Correct 248 ms 8276 KB Output is correct
9 Correct 232 ms 8516 KB Output is correct
10 Correct 230 ms 8532 KB Output is correct
11 Correct 215 ms 10416 KB Output is correct
12 Correct 208 ms 14020 KB Output is correct
13 Correct 207 ms 10184 KB Output is correct
14 Correct 216 ms 12456 KB Output is correct
15 Correct 210 ms 13496 KB Output is correct
16 Correct 223 ms 9160 KB Output is correct
17 Correct 230 ms 9160 KB Output is correct
18 Correct 222 ms 9160 KB Output is correct
19 Correct 254 ms 8652 KB Output is correct
20 Correct 225 ms 8872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -