답안 #977952

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
977952 2024-05-08T14:30:24 Z Kel_Mahmut Gym Badges (NOI22_gymbadges) C++14
100 / 100
456 ms 34088 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;

}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:24:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   24 |   auto [a, Li, Xi] = G[i];
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 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 1 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 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 373 ms 29180 KB Output is correct
2 Correct 321 ms 29008 KB Output is correct
3 Correct 355 ms 29268 KB Output is correct
4 Correct 320 ms 29228 KB Output is correct
5 Correct 329 ms 29248 KB Output is correct
6 Correct 340 ms 28520 KB Output is correct
7 Correct 298 ms 28532 KB Output is correct
8 Correct 367 ms 28460 KB Output is correct
9 Correct 322 ms 28488 KB Output is correct
10 Correct 327 ms 28580 KB Output is correct
11 Correct 306 ms 29364 KB Output is correct
12 Correct 310 ms 32276 KB Output is correct
13 Correct 305 ms 29352 KB Output is correct
14 Correct 329 ms 32692 KB Output is correct
15 Correct 329 ms 31792 KB Output is correct
16 Correct 340 ms 28872 KB Output is correct
17 Correct 299 ms 28836 KB Output is correct
18 Correct 323 ms 28728 KB Output is correct
19 Correct 332 ms 28368 KB Output is correct
20 Correct 299 ms 28372 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 1 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 1 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 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 1 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 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 4 ms 856 KB Output is correct
22 Correct 4 ms 600 KB Output is correct
23 Correct 3 ms 616 KB Output is correct
24 Correct 4 ms 604 KB Output is correct
25 Correct 4 ms 600 KB Output is correct
26 Correct 4 ms 860 KB Output is correct
27 Correct 4 ms 604 KB Output is correct
28 Correct 3 ms 600 KB Output is correct
29 Correct 4 ms 600 KB Output is correct
30 Correct 4 ms 600 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 600 KB Output is correct
34 Correct 5 ms 700 KB Output is correct
35 Correct 5 ms 700 KB Output is correct
36 Correct 3 ms 600 KB Output is correct
37 Correct 3 ms 700 KB Output is correct
38 Correct 4 ms 860 KB Output is correct
39 Correct 3 ms 604 KB Output is correct
40 Correct 3 ms 704 KB Output is correct
41 Correct 4 ms 604 KB Output is correct
42 Correct 3 ms 604 KB Output is correct
43 Correct 4 ms 860 KB Output is correct
44 Correct 4 ms 860 KB Output is correct
45 Correct 4 ms 604 KB Output is correct
46 Correct 5 ms 604 KB Output is correct
47 Correct 3 ms 604 KB Output is correct
48 Correct 3 ms 588 KB Output is correct
49 Correct 3 ms 604 KB Output is correct
50 Correct 3 ms 860 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 1 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 1 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 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 1 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 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 373 ms 29180 KB Output is correct
22 Correct 321 ms 29008 KB Output is correct
23 Correct 355 ms 29268 KB Output is correct
24 Correct 320 ms 29228 KB Output is correct
25 Correct 329 ms 29248 KB Output is correct
26 Correct 340 ms 28520 KB Output is correct
27 Correct 298 ms 28532 KB Output is correct
28 Correct 367 ms 28460 KB Output is correct
29 Correct 322 ms 28488 KB Output is correct
30 Correct 327 ms 28580 KB Output is correct
31 Correct 306 ms 29364 KB Output is correct
32 Correct 310 ms 32276 KB Output is correct
33 Correct 305 ms 29352 KB Output is correct
34 Correct 329 ms 32692 KB Output is correct
35 Correct 329 ms 31792 KB Output is correct
36 Correct 340 ms 28872 KB Output is correct
37 Correct 299 ms 28836 KB Output is correct
38 Correct 323 ms 28728 KB Output is correct
39 Correct 332 ms 28368 KB Output is correct
40 Correct 299 ms 28372 KB Output is correct
41 Correct 4 ms 856 KB Output is correct
42 Correct 4 ms 600 KB Output is correct
43 Correct 3 ms 616 KB Output is correct
44 Correct 4 ms 604 KB Output is correct
45 Correct 4 ms 600 KB Output is correct
46 Correct 4 ms 860 KB Output is correct
47 Correct 4 ms 604 KB Output is correct
48 Correct 3 ms 600 KB Output is correct
49 Correct 4 ms 600 KB Output is correct
50 Correct 4 ms 600 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 600 KB Output is correct
54 Correct 5 ms 700 KB Output is correct
55 Correct 5 ms 700 KB Output is correct
56 Correct 3 ms 600 KB Output is correct
57 Correct 3 ms 700 KB Output is correct
58 Correct 4 ms 860 KB Output is correct
59 Correct 3 ms 604 KB Output is correct
60 Correct 3 ms 704 KB Output is correct
61 Correct 4 ms 604 KB Output is correct
62 Correct 3 ms 604 KB Output is correct
63 Correct 4 ms 860 KB Output is correct
64 Correct 4 ms 860 KB Output is correct
65 Correct 4 ms 604 KB Output is correct
66 Correct 5 ms 604 KB Output is correct
67 Correct 3 ms 604 KB Output is correct
68 Correct 3 ms 588 KB Output is correct
69 Correct 3 ms 604 KB Output is correct
70 Correct 3 ms 860 KB Output is correct
71 Correct 0 ms 344 KB Output is correct
72 Correct 1 ms 604 KB Output is correct
73 Correct 343 ms 29380 KB Output is correct
74 Correct 350 ms 29612 KB Output is correct
75 Correct 319 ms 29372 KB Output is correct
76 Correct 353 ms 29368 KB Output is correct
77 Correct 325 ms 29372 KB Output is correct
78 Correct 324 ms 30260 KB Output is correct
79 Correct 456 ms 30260 KB Output is correct
80 Correct 448 ms 30252 KB Output is correct
81 Correct 329 ms 30152 KB Output is correct
82 Correct 334 ms 30276 KB Output is correct
83 Correct 322 ms 30700 KB Output is correct
84 Correct 338 ms 30704 KB Output is correct
85 Correct 327 ms 30652 KB Output is correct
86 Correct 383 ms 30708 KB Output is correct
87 Correct 324 ms 30620 KB Output is correct
88 Correct 316 ms 33968 KB Output is correct
89 Correct 303 ms 32676 KB Output is correct
90 Correct 331 ms 33448 KB Output is correct
91 Correct 311 ms 34088 KB Output is correct
92 Correct 309 ms 33312 KB Output is correct
93 Correct 320 ms 31912 KB Output is correct
94 Correct 305 ms 32552 KB Output is correct
95 Correct 323 ms 33324 KB Output is correct
96 Correct 309 ms 31920 KB Output is correct
97 Correct 296 ms 31788 KB Output is correct
98 Correct 342 ms 29620 KB Output is correct
99 Correct 333 ms 29624 KB Output is correct
100 Correct 335 ms 29624 KB Output is correct
101 Correct 291 ms 32196 KB Output is correct
102 Correct 286 ms 33088 KB Output is correct