답안 #942309

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942309 2024-03-10T12:36:46 Z vjudge1 Gym Badges (NOI22_gymbadges) C++17
9 / 100
149 ms 25124 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX = 1e6;

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

	int N; cin >> N;
	vector<pair<int, int>> v(N);
	for(int i = 0; i < N; i++) cin >> v[i].second;
	for(int i = 0; i < N; i++) cin >> v[i].first;
	sort(v.begin(), v.end());
	multiset<int> hv;
	int margin = 0;
	int lvl = 0;
	for(pair<int, int>& p : v){
		int L = p.first;
		int X = p.second;
		if(lvl <= L){
			margin = max(margin - X, L - lvl);
			lvl += X;
			hv.insert(X);
		}else if(margin >= X){
			margin = min(margin - X, L - lvl);
			lvl += X;
			hv.insert(X);
		}else{
			int mx = *hv.rbegin();
			if(mx > X){
				hv.erase(hv.find(mx));
				lvl -= mx;
				margin += mx;
				if(lvl <= L){
					margin = max(margin - X, L - lvl);
					lvl += X;
					hv.insert(X);
				}else if(margin >= X){
					margin = min(margin - X, L - lvl);
					lvl += X;
					hv.insert(X);
				}
			}
		}
	}
	cout << (int)hv.size() << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 1 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 1 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 129 ms 13452 KB Output is correct
2 Correct 114 ms 13652 KB Output is correct
3 Correct 116 ms 13652 KB Output is correct
4 Correct 116 ms 13568 KB Output is correct
5 Correct 130 ms 13700 KB Output is correct
6 Correct 119 ms 13448 KB Output is correct
7 Correct 109 ms 12152 KB Output is correct
8 Correct 116 ms 13460 KB Output is correct
9 Correct 117 ms 13392 KB Output is correct
10 Correct 137 ms 13824 KB Output is correct
11 Correct 131 ms 22100 KB Output is correct
12 Correct 149 ms 24048 KB Output is correct
13 Correct 143 ms 23396 KB Output is correct
14 Correct 140 ms 23928 KB Output is correct
15 Correct 149 ms 25124 KB Output is correct
16 Correct 116 ms 15428 KB Output is correct
17 Correct 118 ms 15956 KB Output is correct
18 Correct 120 ms 16468 KB Output is correct
19 Correct 115 ms 14708 KB Output is correct
20 Correct 113 ms 13420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 1 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 1 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 1 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 1 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -