답안 #861696

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861696 2023-10-16T16:41:51 Z wakandaaa Gym Badges (NOI22_gymbadges) C++17
100 / 100
174 ms 22768 KB
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()

#define getbit(x, i) (((x) >> (i)) & 1)
#define bit(x) (1 << (x))
#define popcount __builtin_popcountll

mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
long long rand(long long l, long long r) {
    return l + rd() % (r - l + 1);
}

const int N = 1e6 + 5;
const int mod = 1e9 + 7; // 998244353;
const int lg = 25; // lg + 1
const int inf = 1e9; // INT_MAX;
const long long llinf = 1e18; // LLONG_MAX;

template<class X, class Y>
bool minimize(X &a, Y b) {
    return a > b ? (a = b, true) : false;
}

template<class X, class Y>
bool maximize(X &a, Y b) {
    return a < b ? (a = b, true) : false;
}

template<class X, class Y>
bool add(X &a, Y b) {
    a += b;
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return true;
}

int n;
pair<long long, long long> a[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i].fi;
    for (int i = 1; i <= n; ++i)
        cin >> a[i].se;

    sort(a + 1, a + n + 1, [&] (pair<long long, long long> x, pair<long long, long long> y) {
        return x.fi + x.se < y.fi + y.se;
    });

    priority_queue<long long> q;
    int level = 0, res = 0;
    for (int i = 1; i <= n; ++i) {
        level += a[i].fi;
        q.push(a[i].fi);
        while (level > a[i].fi + a[i].se) {
            level -= q.top();
            q.pop();
        }
        res = max(res, (int) q.size());
    }

    cout << res;

    return 0;
}

/*

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 128 ms 17916 KB Output is correct
2 Correct 125 ms 17916 KB Output is correct
3 Correct 123 ms 17908 KB Output is correct
4 Correct 131 ms 18512 KB Output is correct
5 Correct 125 ms 18072 KB Output is correct
6 Correct 123 ms 17356 KB Output is correct
7 Correct 117 ms 16468 KB Output is correct
8 Correct 125 ms 17524 KB Output is correct
9 Correct 147 ms 17396 KB Output is correct
10 Correct 123 ms 17400 KB Output is correct
11 Correct 108 ms 18124 KB Output is correct
12 Correct 112 ms 20596 KB Output is correct
13 Correct 112 ms 18124 KB Output is correct
14 Correct 108 ms 21360 KB Output is correct
15 Correct 106 ms 21876 KB Output is correct
16 Correct 142 ms 17620 KB Output is correct
17 Correct 121 ms 17620 KB Output is correct
18 Correct 119 ms 17656 KB Output is correct
19 Correct 127 ms 17264 KB Output is correct
20 Correct 122 ms 17044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 592 KB Output is correct
31 Correct 1 ms 476 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 2 ms 604 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 1 ms 604 KB Output is correct
40 Correct 2 ms 536 KB Output is correct
41 Correct 1 ms 604 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 1 ms 600 KB Output is correct
44 Correct 1 ms 604 KB Output is correct
45 Correct 1 ms 604 KB Output is correct
46 Correct 1 ms 604 KB Output is correct
47 Correct 1 ms 604 KB Output is correct
48 Correct 1 ms 608 KB Output is correct
49 Correct 2 ms 604 KB Output is correct
50 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 128 ms 17916 KB Output is correct
22 Correct 125 ms 17916 KB Output is correct
23 Correct 123 ms 17908 KB Output is correct
24 Correct 131 ms 18512 KB Output is correct
25 Correct 125 ms 18072 KB Output is correct
26 Correct 123 ms 17356 KB Output is correct
27 Correct 117 ms 16468 KB Output is correct
28 Correct 125 ms 17524 KB Output is correct
29 Correct 147 ms 17396 KB Output is correct
30 Correct 123 ms 17400 KB Output is correct
31 Correct 108 ms 18124 KB Output is correct
32 Correct 112 ms 20596 KB Output is correct
33 Correct 112 ms 18124 KB Output is correct
34 Correct 108 ms 21360 KB Output is correct
35 Correct 106 ms 21876 KB Output is correct
36 Correct 142 ms 17620 KB Output is correct
37 Correct 121 ms 17620 KB Output is correct
38 Correct 119 ms 17656 KB Output is correct
39 Correct 127 ms 17264 KB Output is correct
40 Correct 122 ms 17044 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 2 ms 604 KB Output is correct
43 Correct 1 ms 604 KB Output is correct
44 Correct 2 ms 604 KB Output is correct
45 Correct 1 ms 604 KB Output is correct
46 Correct 1 ms 604 KB Output is correct
47 Correct 2 ms 600 KB Output is correct
48 Correct 2 ms 604 KB Output is correct
49 Correct 2 ms 604 KB Output is correct
50 Correct 2 ms 592 KB Output is correct
51 Correct 1 ms 476 KB Output is correct
52 Correct 1 ms 604 KB Output is correct
53 Correct 1 ms 604 KB Output is correct
54 Correct 2 ms 604 KB Output is correct
55 Correct 1 ms 604 KB Output is correct
56 Correct 1 ms 604 KB Output is correct
57 Correct 2 ms 604 KB Output is correct
58 Correct 1 ms 604 KB Output is correct
59 Correct 1 ms 604 KB Output is correct
60 Correct 2 ms 536 KB Output is correct
61 Correct 1 ms 604 KB Output is correct
62 Correct 1 ms 604 KB Output is correct
63 Correct 1 ms 600 KB Output is correct
64 Correct 1 ms 604 KB Output is correct
65 Correct 1 ms 604 KB Output is correct
66 Correct 1 ms 604 KB Output is correct
67 Correct 1 ms 604 KB Output is correct
68 Correct 1 ms 608 KB Output is correct
69 Correct 2 ms 604 KB Output is correct
70 Correct 1 ms 604 KB Output is correct
71 Correct 0 ms 596 KB Output is correct
72 Correct 0 ms 348 KB Output is correct
73 Correct 132 ms 18292 KB Output is correct
74 Correct 124 ms 18216 KB Output is correct
75 Correct 144 ms 18224 KB Output is correct
76 Correct 147 ms 18260 KB Output is correct
77 Correct 127 ms 18260 KB Output is correct
78 Correct 133 ms 18896 KB Output is correct
79 Correct 174 ms 18900 KB Output is correct
80 Correct 142 ms 19064 KB Output is correct
81 Correct 144 ms 18940 KB Output is correct
82 Correct 141 ms 19052 KB Output is correct
83 Correct 149 ms 19568 KB Output is correct
84 Correct 143 ms 19544 KB Output is correct
85 Correct 147 ms 19548 KB Output is correct
86 Correct 138 ms 19332 KB Output is correct
87 Correct 138 ms 19484 KB Output is correct
88 Correct 133 ms 21708 KB Output is correct
89 Correct 132 ms 22768 KB Output is correct
90 Correct 133 ms 20848 KB Output is correct
91 Correct 133 ms 21340 KB Output is correct
92 Correct 132 ms 22508 KB Output is correct
93 Correct 126 ms 21292 KB Output is correct
94 Correct 117 ms 21748 KB Output is correct
95 Correct 118 ms 20724 KB Output is correct
96 Correct 119 ms 20876 KB Output is correct
97 Correct 117 ms 21364 KB Output is correct
98 Correct 138 ms 18440 KB Output is correct
99 Correct 146 ms 18428 KB Output is correct
100 Correct 134 ms 18704 KB Output is correct
101 Correct 116 ms 20324 KB Output is correct
102 Correct 118 ms 20624 KB Output is correct