# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
886966 | 2023-12-13T09:38:21 Z | efedmrlr | Gym Badges (NOI22_gymbadges) | C++17 | 345 ms | 29892 KB |
#include <bits/stdc++.h> #define int long long int #define MP make_pair #define REP(i,n) for(int (i) = 0; (i)<(n); (i)++) #define pb push_back const int N = 5e3+5; const int MOD = 1e9+7; const int INF = 1e17; using namespace std; void fastio() { ios_base::sync_with_stdio(0); cin.tie(NULL); } int n,m,q; vector<int> dp(N, INF), dpnew(N, INF); vector<int> L, X; vector<array<int,2> > srt; bool comp(array<int,2> &x, array<int,2> &y) { return x[0] + x[1] < y[0] + y[1]; } void solve() { cin>>n; srt.resize(n); L.assign(n+1, 0); X.assign(n+1, 0); REP(i,n) cin>>srt[i][0]; REP(i,n) cin>>srt[i][1]; dp[0] = 0; sort(srt.begin(), srt.end(), comp); REP(i,n) { X[i + 1] = srt[i][0]; L[i + 1] = srt[i][1]; } priority_queue<int> pq; int last = 0; for(int i = 1; i<=n; i++) { pq.push(X[i]); if(last > L[i]) { last -= pq.top(); pq.pop(); // pop worst } last += X[i]; } cout<<pq.size()<<"\n"; } signed main() { // fastio(); solve(); }
Compilation message
# | Verdict | Execution time | Memory | 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 | 0 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 | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 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 | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 316 ms | 16148 KB | Output is correct |
2 | Correct | 322 ms | 25204 KB | Output is correct |
3 | Correct | 317 ms | 25428 KB | Output is correct |
4 | Correct | 326 ms | 25204 KB | Output is correct |
5 | Correct | 319 ms | 25428 KB | Output is correct |
6 | Correct | 303 ms | 24604 KB | Output is correct |
7 | Correct | 291 ms | 23888 KB | Output is correct |
8 | Correct | 307 ms | 24712 KB | Output is correct |
9 | Correct | 303 ms | 24656 KB | Output is correct |
10 | Correct | 306 ms | 24712 KB | Output is correct |
11 | Correct | 272 ms | 25544 KB | Output is correct |
12 | Correct | 269 ms | 28356 KB | Output is correct |
13 | Correct | 285 ms | 25676 KB | Output is correct |
14 | Correct | 272 ms | 29640 KB | Output is correct |
15 | Correct | 274 ms | 28412 KB | Output is correct |
16 | Correct | 294 ms | 24832 KB | Output is correct |
17 | Correct | 293 ms | 25040 KB | Output is correct |
18 | Correct | 294 ms | 24836 KB | Output is correct |
19 | Correct | 296 ms | 24532 KB | Output is correct |
20 | Correct | 298 ms | 24740 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 0 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 | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 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 | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 364 KB | Output is correct |
21 | Correct | 3 ms | 604 KB | Output is correct |
22 | Correct | 3 ms | 604 KB | Output is correct |
23 | Correct | 3 ms | 604 KB | Output is correct |
24 | Correct | 3 ms | 604 KB | Output is correct |
25 | Correct | 3 ms | 604 KB | Output is correct |
26 | Correct | 3 ms | 604 KB | Output is correct |
27 | Correct | 3 ms | 604 KB | Output is correct |
28 | Correct | 3 ms | 664 KB | Output is correct |
29 | Correct | 3 ms | 604 KB | Output is correct |
30 | Correct | 3 ms | 604 KB | Output is correct |
31 | Correct | 4 ms | 604 KB | Output is correct |
32 | Correct | 3 ms | 604 KB | Output is correct |
33 | Correct | 3 ms | 604 KB | Output is correct |
34 | Correct | 3 ms | 604 KB | Output is correct |
35 | Correct | 3 ms | 604 KB | Output is correct |
36 | Correct | 3 ms | 664 KB | Output is correct |
37 | Correct | 3 ms | 604 KB | Output is correct |
38 | Correct | 3 ms | 604 KB | Output is correct |
39 | Correct | 3 ms | 604 KB | Output is correct |
40 | Correct | 3 ms | 604 KB | Output is correct |
41 | Correct | 3 ms | 604 KB | Output is correct |
42 | Correct | 3 ms | 604 KB | Output is correct |
43 | Correct | 3 ms | 604 KB | Output is correct |
44 | Correct | 3 ms | 604 KB | Output is correct |
45 | Correct | 3 ms | 668 KB | Output is correct |
46 | Correct | 3 ms | 604 KB | Output is correct |
47 | Correct | 3 ms | 664 KB | Output is correct |
48 | Correct | 3 ms | 600 KB | Output is correct |
49 | Correct | 3 ms | 604 KB | Output is correct |
50 | Correct | 3 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 0 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 | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 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 | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 364 KB | Output is correct |
21 | Correct | 316 ms | 16148 KB | Output is correct |
22 | Correct | 322 ms | 25204 KB | Output is correct |
23 | Correct | 317 ms | 25428 KB | Output is correct |
24 | Correct | 326 ms | 25204 KB | Output is correct |
25 | Correct | 319 ms | 25428 KB | Output is correct |
26 | Correct | 303 ms | 24604 KB | Output is correct |
27 | Correct | 291 ms | 23888 KB | Output is correct |
28 | Correct | 307 ms | 24712 KB | Output is correct |
29 | Correct | 303 ms | 24656 KB | Output is correct |
30 | Correct | 306 ms | 24712 KB | Output is correct |
31 | Correct | 272 ms | 25544 KB | Output is correct |
32 | Correct | 269 ms | 28356 KB | Output is correct |
33 | Correct | 285 ms | 25676 KB | Output is correct |
34 | Correct | 272 ms | 29640 KB | Output is correct |
35 | Correct | 274 ms | 28412 KB | Output is correct |
36 | Correct | 294 ms | 24832 KB | Output is correct |
37 | Correct | 293 ms | 25040 KB | Output is correct |
38 | Correct | 294 ms | 24836 KB | Output is correct |
39 | Correct | 296 ms | 24532 KB | Output is correct |
40 | Correct | 298 ms | 24740 KB | Output is correct |
41 | Correct | 3 ms | 604 KB | Output is correct |
42 | Correct | 3 ms | 604 KB | Output is correct |
43 | Correct | 3 ms | 604 KB | Output is correct |
44 | Correct | 3 ms | 604 KB | Output is correct |
45 | Correct | 3 ms | 604 KB | Output is correct |
46 | Correct | 3 ms | 604 KB | Output is correct |
47 | Correct | 3 ms | 604 KB | Output is correct |
48 | Correct | 3 ms | 664 KB | Output is correct |
49 | Correct | 3 ms | 604 KB | Output is correct |
50 | Correct | 3 ms | 604 KB | Output is correct |
51 | Correct | 4 ms | 604 KB | Output is correct |
52 | Correct | 3 ms | 604 KB | Output is correct |
53 | Correct | 3 ms | 604 KB | Output is correct |
54 | Correct | 3 ms | 604 KB | Output is correct |
55 | Correct | 3 ms | 604 KB | Output is correct |
56 | Correct | 3 ms | 664 KB | Output is correct |
57 | Correct | 3 ms | 604 KB | Output is correct |
58 | Correct | 3 ms | 604 KB | Output is correct |
59 | Correct | 3 ms | 604 KB | Output is correct |
60 | Correct | 3 ms | 604 KB | Output is correct |
61 | Correct | 3 ms | 604 KB | Output is correct |
62 | Correct | 3 ms | 604 KB | Output is correct |
63 | Correct | 3 ms | 604 KB | Output is correct |
64 | Correct | 3 ms | 604 KB | Output is correct |
65 | Correct | 3 ms | 668 KB | Output is correct |
66 | Correct | 3 ms | 604 KB | Output is correct |
67 | Correct | 3 ms | 664 KB | Output is correct |
68 | Correct | 3 ms | 600 KB | Output is correct |
69 | Correct | 3 ms | 604 KB | Output is correct |
70 | Correct | 3 ms | 604 KB | Output is correct |
71 | Correct | 0 ms | 344 KB | Output is correct |
72 | Correct | 1 ms | 348 KB | Output is correct |
73 | Correct | 322 ms | 25512 KB | Output is correct |
74 | Correct | 320 ms | 25428 KB | Output is correct |
75 | Correct | 327 ms | 25684 KB | Output is correct |
76 | Correct | 326 ms | 25484 KB | Output is correct |
77 | Correct | 324 ms | 25532 KB | Output is correct |
78 | Correct | 322 ms | 26380 KB | Output is correct |
79 | Correct | 321 ms | 26392 KB | Output is correct |
80 | Correct | 324 ms | 26316 KB | Output is correct |
81 | Correct | 320 ms | 26356 KB | Output is correct |
82 | Correct | 345 ms | 26248 KB | Output is correct |
83 | Correct | 319 ms | 26848 KB | Output is correct |
84 | Correct | 316 ms | 26632 KB | Output is correct |
85 | Correct | 315 ms | 26864 KB | Output is correct |
86 | Correct | 312 ms | 26680 KB | Output is correct |
87 | Correct | 314 ms | 26848 KB | Output is correct |
88 | Correct | 300 ms | 29092 KB | Output is correct |
89 | Correct | 294 ms | 29124 KB | Output is correct |
90 | Correct | 309 ms | 28300 KB | Output is correct |
91 | Correct | 296 ms | 29384 KB | Output is correct |
92 | Correct | 305 ms | 28300 KB | Output is correct |
93 | Correct | 286 ms | 27844 KB | Output is correct |
94 | Correct | 297 ms | 29892 KB | Output is correct |
95 | Correct | 285 ms | 28436 KB | Output is correct |
96 | Correct | 287 ms | 28360 KB | Output is correct |
97 | Correct | 285 ms | 29536 KB | Output is correct |
98 | Correct | 322 ms | 25680 KB | Output is correct |
99 | Correct | 328 ms | 25940 KB | Output is correct |
100 | Correct | 326 ms | 25744 KB | Output is correct |
101 | Correct | 274 ms | 27400 KB | Output is correct |
102 | Correct | 270 ms | 28100 KB | Output is correct |