답안 #942338

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942338 2024-03-10T13:05:39 Z vjudge1 Gym Badges (NOI22_gymbadges) C++17
100 / 100
354 ms 36856 KB
#include <bits/stdc++.h>

using namespace std;

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

	int N; cin >> N;
	vector<tuple<int, int, int>> v(N, {0,0,0});
	for(int i = 0; i < N; i++){
		int X; cin >> X;
		get<0>(v[i]) += X;
		get<1>(v[i]) = X;
	}
	for(int i = 0; i < N; i++){
		int L; cin >> L;
		get<0>(v[i]) += L;
		get<2>(v[i]) = L;
	}
	sort(v.begin(), v.end());
	multiset<int> hv;
	int ans = 0;
	int lvl = 0;
	for(int i = 0; i < N; i++){
		// cout << get<0>(v[i]) << " " << get<1>(v[i]) << " " << get<2>(v[i]) << "\n";
		if(lvl <= get<2>(v[i])){
			ans++;
			lvl += get<1>(v[i]);
			hv.insert(get<1>(v[i]));
		}else{
			int mx = *hv.rbegin();
			if(mx <= get<1>(v[i])) continue;
			hv.erase(hv.find(mx));
			lvl -= mx; ans--;
			if(lvl <= get<2>(v[i])){
				ans++;
				lvl += get<1>(v[i]);
				hv.insert(get<1>(v[i]));
			}
		}
	}
	cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 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 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 456 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 6304 KB Output is correct
2 Correct 116 ms 6332 KB Output is correct
3 Correct 108 ms 6316 KB Output is correct
4 Correct 111 ms 6304 KB Output is correct
5 Correct 118 ms 6312 KB Output is correct
6 Correct 108 ms 7084 KB Output is correct
7 Correct 103 ms 6312 KB Output is correct
8 Correct 121 ms 6996 KB Output is correct
9 Correct 110 ms 7252 KB Output is correct
10 Correct 109 ms 7764 KB Output is correct
11 Correct 139 ms 16800 KB Output is correct
12 Correct 143 ms 18772 KB Output is correct
13 Correct 140 ms 18084 KB Output is correct
14 Correct 142 ms 18600 KB Output is correct
15 Correct 145 ms 19632 KB Output is correct
16 Correct 113 ms 9380 KB Output is correct
17 Correct 116 ms 10152 KB Output is correct
18 Correct 119 ms 10684 KB Output is correct
19 Correct 112 ms 8868 KB Output is correct
20 Correct 108 ms 7844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 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 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 456 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 600 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 2 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 600 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 2 ms 604 KB Output is correct
36 Correct 2 ms 600 KB Output is correct
37 Correct 2 ms 604 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 2 ms 604 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 2 ms 604 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 3 ms 604 KB Output is correct
47 Correct 2 ms 604 KB Output is correct
48 Correct 2 ms 604 KB Output is correct
49 Correct 2 ms 600 KB Output is correct
50 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 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 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 456 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 119 ms 6304 KB Output is correct
22 Correct 116 ms 6332 KB Output is correct
23 Correct 108 ms 6316 KB Output is correct
24 Correct 111 ms 6304 KB Output is correct
25 Correct 118 ms 6312 KB Output is correct
26 Correct 108 ms 7084 KB Output is correct
27 Correct 103 ms 6312 KB Output is correct
28 Correct 121 ms 6996 KB Output is correct
29 Correct 110 ms 7252 KB Output is correct
30 Correct 109 ms 7764 KB Output is correct
31 Correct 139 ms 16800 KB Output is correct
32 Correct 143 ms 18772 KB Output is correct
33 Correct 140 ms 18084 KB Output is correct
34 Correct 142 ms 18600 KB Output is correct
35 Correct 145 ms 19632 KB Output is correct
36 Correct 113 ms 9380 KB Output is correct
37 Correct 116 ms 10152 KB Output is correct
38 Correct 119 ms 10684 KB Output is correct
39 Correct 112 ms 8868 KB Output is correct
40 Correct 108 ms 7844 KB Output is correct
41 Correct 1 ms 600 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 2 ms 604 KB Output is correct
46 Correct 2 ms 604 KB Output is correct
47 Correct 2 ms 604 KB Output is correct
48 Correct 2 ms 604 KB Output is correct
49 Correct 2 ms 600 KB Output is correct
50 Correct 2 ms 604 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
52 Correct 2 ms 604 KB Output is correct
53 Correct 2 ms 604 KB Output is correct
54 Correct 2 ms 604 KB Output is correct
55 Correct 2 ms 604 KB Output is correct
56 Correct 2 ms 600 KB Output is correct
57 Correct 2 ms 604 KB Output is correct
58 Correct 2 ms 604 KB Output is correct
59 Correct 2 ms 604 KB Output is correct
60 Correct 2 ms 604 KB Output is correct
61 Correct 2 ms 604 KB Output is correct
62 Correct 2 ms 604 KB Output is correct
63 Correct 2 ms 604 KB Output is correct
64 Correct 2 ms 604 KB Output is correct
65 Correct 2 ms 604 KB Output is correct
66 Correct 3 ms 604 KB Output is correct
67 Correct 2 ms 604 KB Output is correct
68 Correct 2 ms 604 KB Output is correct
69 Correct 2 ms 600 KB Output is correct
70 Correct 2 ms 604 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 1 ms 344 KB Output is correct
73 Correct 122 ms 15960 KB Output is correct
74 Correct 122 ms 15952 KB Output is correct
75 Correct 116 ms 15912 KB Output is correct
76 Correct 121 ms 15812 KB Output is correct
77 Correct 119 ms 16032 KB Output is correct
78 Correct 133 ms 18760 KB Output is correct
79 Correct 138 ms 18864 KB Output is correct
80 Correct 138 ms 18720 KB Output is correct
81 Correct 135 ms 18728 KB Output is correct
82 Correct 137 ms 18772 KB Output is correct
83 Correct 176 ms 24076 KB Output is correct
84 Correct 170 ms 24084 KB Output is correct
85 Correct 179 ms 24076 KB Output is correct
86 Correct 193 ms 24000 KB Output is correct
87 Correct 172 ms 24076 KB Output is correct
88 Correct 245 ms 29268 KB Output is correct
89 Correct 223 ms 29484 KB Output is correct
90 Correct 232 ms 29520 KB Output is correct
91 Correct 215 ms 29528 KB Output is correct
92 Correct 220 ms 29780 KB Output is correct
93 Correct 264 ms 32556 KB Output is correct
94 Correct 266 ms 32576 KB Output is correct
95 Correct 277 ms 32516 KB Output is correct
96 Correct 264 ms 32428 KB Output is correct
97 Correct 265 ms 32596 KB Output is correct
98 Correct 116 ms 16468 KB Output is correct
99 Correct 116 ms 16420 KB Output is correct
100 Correct 117 ms 16468 KB Output is correct
101 Correct 319 ms 36856 KB Output is correct
102 Correct 354 ms 36692 KB Output is correct