Submission #998746

# Submission time Handle Problem Language Result Execution time Memory
998746 2024-06-14T15:52:59 Z LOLOLO Gym Badges (NOI22_gymbadges) C++14
24 / 100
124 ms 14664 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define           f     first
#define           s     second
#define           pb    push_back
#define           ep    emplace
#define           eb    emplace_back
#define           lb    lower_bound
#define           ub    upper_bound
#define       all(x)    x.begin(), x.end()
#define      rall(x)    x.rbegin(), x.rend()
#define   uniquev(v)    sort(all(v)), (v).resize(unique(all(v)) - (v).begin())
#define     mem(f,x)    memset(f , x , sizeof(f))
#define        sz(x)    (ll)(x).size()
#define  __lcm(a, b)    (1ll * ((a) / __gcd((a), (b))) * (b))
#define          mxx    *max_element
#define          mnn    *min_element
#define    cntbit(x)    __builtin_popcountll(x)
#define       len(x)    (int)(x.length())
 
const int N = 1e6 + 10;
int x[N], l[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    for (int i = 1; i <= n; i++)
        cin >> x[i];

    vector <int> order;
    for (int i = 1; i <= n; i++) {
        cin >> l[i];
        order.pb(i);
    }

    sort(all(order), [&] (int a, int b) { return make_pair(x[a] + l[a], x[a]) < make_pair(x[b] + l[b], x[b]);});
    priority_queue <ll> pq;
    ll sum = 0;

    for (auto i : order) {
        if (sum <= l[i]) {
            sum += x[i];
            pq.push(x[i]);
        } else {
            if (pq.empty())
                continue;

            ll t = pq.top();
            if (t > x[i] && sum - t + x[i] <= l[i]) {
                pq.pop();
                pq.push(x[i]);
                sum += (x[i] - t);
            }
        }
    }

    cout << sz(pq) << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 117 ms 8908 KB Output is correct
2 Correct 121 ms 8908 KB Output is correct
3 Correct 116 ms 8912 KB Output is correct
4 Correct 124 ms 8908 KB Output is correct
5 Correct 117 ms 8908 KB Output is correct
6 Correct 115 ms 9160 KB Output is correct
7 Correct 110 ms 8908 KB Output is correct
8 Correct 111 ms 8912 KB Output is correct
9 Correct 112 ms 9156 KB Output is correct
10 Correct 115 ms 9132 KB Output is correct
11 Correct 100 ms 11648 KB Output is correct
12 Correct 120 ms 13912 KB Output is correct
13 Correct 101 ms 11720 KB Output is correct
14 Correct 101 ms 13000 KB Output is correct
15 Correct 101 ms 14664 KB Output is correct
16 Correct 109 ms 10180 KB Output is correct
17 Correct 112 ms 10272 KB Output is correct
18 Correct 113 ms 10440 KB Output is correct
19 Correct 110 ms 9668 KB Output is correct
20 Correct 112 ms 9416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Incorrect 1 ms 2396 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 117 ms 8908 KB Output is correct
22 Correct 121 ms 8908 KB Output is correct
23 Correct 116 ms 8912 KB Output is correct
24 Correct 124 ms 8908 KB Output is correct
25 Correct 117 ms 8908 KB Output is correct
26 Correct 115 ms 9160 KB Output is correct
27 Correct 110 ms 8908 KB Output is correct
28 Correct 111 ms 8912 KB Output is correct
29 Correct 112 ms 9156 KB Output is correct
30 Correct 115 ms 9132 KB Output is correct
31 Correct 100 ms 11648 KB Output is correct
32 Correct 120 ms 13912 KB Output is correct
33 Correct 101 ms 11720 KB Output is correct
34 Correct 101 ms 13000 KB Output is correct
35 Correct 101 ms 14664 KB Output is correct
36 Correct 109 ms 10180 KB Output is correct
37 Correct 112 ms 10272 KB Output is correct
38 Correct 113 ms 10440 KB Output is correct
39 Correct 110 ms 9668 KB Output is correct
40 Correct 112 ms 9416 KB Output is correct
41 Incorrect 1 ms 2396 KB Output isn't correct
42 Halted 0 ms 0 KB -