답안 #886677

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886677 2023-12-12T16:02:32 Z vjudge1 Gym Badges (NOI22_gymbadges) C++17
100 / 100
351 ms 33944 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;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 436 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 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 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 356 KB Output is correct
15 Correct 0 ms 352 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 352 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 351 ms 24664 KB Output is correct
2 Correct 328 ms 29008 KB Output is correct
3 Correct 336 ms 29224 KB Output is correct
4 Correct 325 ms 29228 KB Output is correct
5 Correct 325 ms 29100 KB Output is correct
6 Correct 320 ms 28580 KB Output is correct
7 Correct 306 ms 27836 KB Output is correct
8 Correct 310 ms 28336 KB Output is correct
9 Correct 306 ms 28472 KB Output is correct
10 Correct 302 ms 28500 KB Output is correct
11 Correct 283 ms 29208 KB Output is correct
12 Correct 287 ms 32156 KB Output is correct
13 Correct 290 ms 29404 KB Output is correct
14 Correct 283 ms 31388 KB Output is correct
15 Correct 283 ms 31424 KB Output is correct
16 Correct 296 ms 28872 KB Output is correct
17 Correct 293 ms 28696 KB Output is correct
18 Correct 297 ms 28704 KB Output is correct
19 Correct 293 ms 28364 KB Output is correct
20 Correct 295 ms 28368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 436 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 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 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 356 KB Output is correct
15 Correct 0 ms 352 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 352 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 3 ms 604 KB Output is correct
22 Correct 3 ms 700 KB Output is correct
23 Correct 3 ms 700 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 704 KB Output is correct
28 Correct 4 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 5 ms 604 KB Output is correct
32 Correct 3 ms 600 KB Output is correct
33 Correct 3 ms 604 KB Output is correct
34 Correct 3 ms 596 KB Output is correct
35 Correct 5 ms 848 KB Output is correct
36 Correct 3 ms 604 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 596 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 704 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 600 KB Output is correct
49 Correct 3 ms 604 KB Output is correct
50 Correct 3 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 436 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 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 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 356 KB Output is correct
15 Correct 0 ms 352 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 352 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 351 ms 24664 KB Output is correct
22 Correct 328 ms 29008 KB Output is correct
23 Correct 336 ms 29224 KB Output is correct
24 Correct 325 ms 29228 KB Output is correct
25 Correct 325 ms 29100 KB Output is correct
26 Correct 320 ms 28580 KB Output is correct
27 Correct 306 ms 27836 KB Output is correct
28 Correct 310 ms 28336 KB Output is correct
29 Correct 306 ms 28472 KB Output is correct
30 Correct 302 ms 28500 KB Output is correct
31 Correct 283 ms 29208 KB Output is correct
32 Correct 287 ms 32156 KB Output is correct
33 Correct 290 ms 29404 KB Output is correct
34 Correct 283 ms 31388 KB Output is correct
35 Correct 283 ms 31424 KB Output is correct
36 Correct 296 ms 28872 KB Output is correct
37 Correct 293 ms 28696 KB Output is correct
38 Correct 297 ms 28704 KB Output is correct
39 Correct 293 ms 28364 KB Output is correct
40 Correct 295 ms 28368 KB Output is correct
41 Correct 3 ms 604 KB Output is correct
42 Correct 3 ms 700 KB Output is correct
43 Correct 3 ms 700 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 704 KB Output is correct
48 Correct 4 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 5 ms 604 KB Output is correct
52 Correct 3 ms 600 KB Output is correct
53 Correct 3 ms 604 KB Output is correct
54 Correct 3 ms 596 KB Output is correct
55 Correct 5 ms 848 KB Output is correct
56 Correct 3 ms 604 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 596 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 704 KB Output is correct
65 Correct 3 ms 604 KB Output is correct
66 Correct 3 ms 604 KB Output is correct
67 Correct 3 ms 604 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 0 ms 436 KB Output is correct
73 Correct 329 ms 29364 KB Output is correct
74 Correct 319 ms 29360 KB Output is correct
75 Correct 326 ms 29624 KB Output is correct
76 Correct 317 ms 29268 KB Output is correct
77 Correct 331 ms 29372 KB Output is correct
78 Correct 315 ms 30116 KB Output is correct
79 Correct 323 ms 30416 KB Output is correct
80 Correct 315 ms 30152 KB Output is correct
81 Correct 321 ms 30116 KB Output is correct
82 Correct 314 ms 30128 KB Output is correct
83 Correct 329 ms 30664 KB Output is correct
84 Correct 318 ms 30496 KB Output is correct
85 Correct 308 ms 30664 KB Output is correct
86 Correct 312 ms 30664 KB Output is correct
87 Correct 311 ms 30688 KB Output is correct
88 Correct 319 ms 32540 KB Output is correct
89 Correct 297 ms 32892 KB Output is correct
90 Correct 296 ms 32812 KB Output is correct
91 Correct 298 ms 33944 KB Output is correct
92 Correct 296 ms 33916 KB Output is correct
93 Correct 305 ms 33436 KB Output is correct
94 Correct 290 ms 33552 KB Output is correct
95 Correct 295 ms 33728 KB Output is correct
96 Correct 289 ms 32536 KB Output is correct
97 Correct 286 ms 32528 KB Output is correct
98 Correct 319 ms 29564 KB Output is correct
99 Correct 320 ms 29476 KB Output is correct
100 Correct 322 ms 29740 KB Output is correct
101 Correct 282 ms 31936 KB Output is correct
102 Correct 296 ms 31260 KB Output is correct