Submission #966582

# Submission time Handle Problem Language Result Execution time Memory
966582 2024-04-20T05:19:15 Z Trisanu_Das Gym Badges (NOI22_gymbadges) C++17
100 / 100
338 ms 34080 KB
#include <bits/stdc++.h>
#define pb push_back
#define all(aa) aa.begin(), aa.end()
using namespace std;
typedef long long ll;
 
int main(){
	int n;
	cin >> n;
	vector<ll> L(n), X(n);
	for(int i = 0; i < n; i++)
		cin >> X[i];
	for(int i = 0; i < n; i++)
		cin >> L[i];
	vector<array<ll, 3>> G(n);
	for(int i = 0; i < n; i++){
		G[i] = {L[i] + X[i], L[i], X[i]};
	}
	sort(all(G));
 
	priority_queue<ll> vals;
	ll score = 0, ans = 0;
	for(int i = 0; i < n; i++){
		auto [a, Li, Xi] = G[i];
		if(score <= Li){
			vals.push(Xi);
			score += Xi;
			ans++;
		}
		else if(vals.top() > Xi){
			score -= vals.top(); vals.pop();
			score += Xi; vals.push(Xi); 
		}
	}
	cout << ans << endl;
 
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 1 ms 344 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 436 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 440 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 322 ms 29108 KB Output is correct
2 Correct 334 ms 29104 KB Output is correct
3 Correct 322 ms 29248 KB Output is correct
4 Correct 324 ms 29356 KB Output is correct
5 Correct 328 ms 29268 KB Output is correct
6 Correct 302 ms 28688 KB Output is correct
7 Correct 290 ms 27956 KB Output is correct
8 Correct 298 ms 28452 KB Output is correct
9 Correct 321 ms 28716 KB Output is correct
10 Correct 298 ms 28584 KB Output is correct
11 Correct 314 ms 29472 KB Output is correct
12 Correct 294 ms 33476 KB Output is correct
13 Correct 285 ms 29640 KB Output is correct
14 Correct 303 ms 32004 KB Output is correct
15 Correct 282 ms 31752 KB Output is correct
16 Correct 295 ms 28700 KB Output is correct
17 Correct 292 ms 28848 KB Output is correct
18 Correct 309 ms 28968 KB Output is correct
19 Correct 291 ms 28328 KB Output is correct
20 Correct 298 ms 28328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 1 ms 344 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 436 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 440 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 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 3 ms 600 KB Output is correct
22 Correct 4 ms 604 KB Output is correct
23 Correct 4 ms 600 KB Output is correct
24 Correct 4 ms 604 KB Output is correct
25 Correct 4 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 604 KB Output is correct
29 Correct 3 ms 604 KB Output is correct
30 Correct 4 ms 604 KB Output is correct
31 Correct 4 ms 600 KB Output is correct
32 Correct 3 ms 604 KB Output is correct
33 Correct 4 ms 708 KB Output is correct
34 Correct 3 ms 604 KB Output is correct
35 Correct 4 ms 604 KB Output is correct
36 Correct 3 ms 604 KB Output is correct
37 Correct 3 ms 600 KB Output is correct
38 Correct 3 ms 604 KB Output is correct
39 Correct 4 ms 604 KB Output is correct
40 Correct 3 ms 708 KB Output is correct
41 Correct 4 ms 572 KB Output is correct
42 Correct 3 ms 600 KB Output is correct
43 Correct 5 ms 604 KB Output is correct
44 Correct 4 ms 712 KB Output is correct
45 Correct 3 ms 592 KB Output is correct
46 Correct 4 ms 604 KB Output is correct
47 Correct 3 ms 604 KB Output is correct
48 Correct 3 ms 596 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 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 1 ms 344 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 436 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 440 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 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 322 ms 29108 KB Output is correct
22 Correct 334 ms 29104 KB Output is correct
23 Correct 322 ms 29248 KB Output is correct
24 Correct 324 ms 29356 KB Output is correct
25 Correct 328 ms 29268 KB Output is correct
26 Correct 302 ms 28688 KB Output is correct
27 Correct 290 ms 27956 KB Output is correct
28 Correct 298 ms 28452 KB Output is correct
29 Correct 321 ms 28716 KB Output is correct
30 Correct 298 ms 28584 KB Output is correct
31 Correct 314 ms 29472 KB Output is correct
32 Correct 294 ms 33476 KB Output is correct
33 Correct 285 ms 29640 KB Output is correct
34 Correct 303 ms 32004 KB Output is correct
35 Correct 282 ms 31752 KB Output is correct
36 Correct 295 ms 28700 KB Output is correct
37 Correct 292 ms 28848 KB Output is correct
38 Correct 309 ms 28968 KB Output is correct
39 Correct 291 ms 28328 KB Output is correct
40 Correct 298 ms 28328 KB Output is correct
41 Correct 3 ms 600 KB Output is correct
42 Correct 4 ms 604 KB Output is correct
43 Correct 4 ms 600 KB Output is correct
44 Correct 4 ms 604 KB Output is correct
45 Correct 4 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 604 KB Output is correct
49 Correct 3 ms 604 KB Output is correct
50 Correct 4 ms 604 KB Output is correct
51 Correct 4 ms 600 KB Output is correct
52 Correct 3 ms 604 KB Output is correct
53 Correct 4 ms 708 KB Output is correct
54 Correct 3 ms 604 KB Output is correct
55 Correct 4 ms 604 KB Output is correct
56 Correct 3 ms 604 KB Output is correct
57 Correct 3 ms 600 KB Output is correct
58 Correct 3 ms 604 KB Output is correct
59 Correct 4 ms 604 KB Output is correct
60 Correct 3 ms 708 KB Output is correct
61 Correct 4 ms 572 KB Output is correct
62 Correct 3 ms 600 KB Output is correct
63 Correct 5 ms 604 KB Output is correct
64 Correct 4 ms 712 KB Output is correct
65 Correct 3 ms 592 KB Output is correct
66 Correct 4 ms 604 KB Output is correct
67 Correct 3 ms 604 KB Output is correct
68 Correct 3 ms 596 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 325 ms 29368 KB Output is correct
74 Correct 318 ms 29264 KB Output is correct
75 Correct 331 ms 29396 KB Output is correct
76 Correct 323 ms 29264 KB Output is correct
77 Correct 324 ms 29500 KB Output is correct
78 Correct 314 ms 30256 KB Output is correct
79 Correct 321 ms 30704 KB Output is correct
80 Correct 317 ms 30252 KB Output is correct
81 Correct 334 ms 30500 KB Output is correct
82 Correct 319 ms 30256 KB Output is correct
83 Correct 313 ms 30660 KB Output is correct
84 Correct 321 ms 30644 KB Output is correct
85 Correct 314 ms 30660 KB Output is correct
86 Correct 318 ms 30636 KB Output is correct
87 Correct 338 ms 30640 KB Output is correct
88 Correct 307 ms 32812 KB Output is correct
89 Correct 308 ms 33172 KB Output is correct
90 Correct 310 ms 34080 KB Output is correct
91 Correct 304 ms 33176 KB Output is correct
92 Correct 303 ms 33836 KB Output is correct
93 Correct 292 ms 32708 KB Output is correct
94 Correct 294 ms 32672 KB Output is correct
95 Correct 292 ms 33216 KB Output is correct
96 Correct 292 ms 32192 KB Output is correct
97 Correct 331 ms 32236 KB Output is correct
98 Correct 320 ms 29524 KB Output is correct
99 Correct 334 ms 29776 KB Output is correct
100 Correct 328 ms 29628 KB Output is correct
101 Correct 294 ms 33216 KB Output is correct
102 Correct 279 ms 33064 KB Output is correct