답안 #886533

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886533 2023-12-12T09:39:00 Z vjudge1 Gym Badges (NOI22_gymbadges) C++17
24 / 100
2000 ms 26224 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<pair<ll, ll>> G(n);
	for(int i = 0; i < n; i++){
		G[i] = make_pair(L[i], X[i]);
	}
	sort(all(G));

	bool constant = 1;
	for(int i = 1; i < n; i++){
		if(L[i] != L[i-1]) constant = 0;
	}
	if(constant){
		

		priority_queue<ll> vals;
		ll score = 0, ans = 0;
		for(int i = 0; i < n; i++){
			auto [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;
	}
	else{
		vector<int> perm(n);
		iota(all(perm), 0);
		int ok = 1;
		int cev = 0;
		while(ok){
			int score = 0, ans = 0;
			for(int cur = 0; cur < n; cur++){
				int i = perm[cur];
				auto [Li, Xi] = G[i];
				if(score <= Li){
					score+=Xi;
					ans++;
				}
			}
			cev = max(ans, cev);
			ok = next_permutation(all(perm));
		}

		cout << cev << endl;
	}

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 50 ms 428 KB Output is correct
4 Correct 49 ms 412 KB Output is correct
5 Correct 43 ms 348 KB Output is correct
6 Correct 48 ms 412 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 48 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 436 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 56 ms 408 KB Output is correct
14 Correct 47 ms 344 KB Output is correct
15 Correct 47 ms 428 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 6 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 59 ms 348 KB Output is correct
20 Correct 60 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 308 ms 21268 KB Output is correct
2 Correct 308 ms 21332 KB Output is correct
3 Correct 311 ms 21456 KB Output is correct
4 Correct 308 ms 21328 KB Output is correct
5 Correct 312 ms 21308 KB Output is correct
6 Correct 290 ms 21256 KB Output is correct
7 Correct 283 ms 20840 KB Output is correct
8 Correct 288 ms 21072 KB Output is correct
9 Correct 299 ms 21380 KB Output is correct
10 Correct 308 ms 21352 KB Output is correct
11 Correct 266 ms 22448 KB Output is correct
12 Correct 270 ms 26224 KB Output is correct
13 Correct 266 ms 22392 KB Output is correct
14 Correct 292 ms 25024 KB Output is correct
15 Correct 269 ms 24948 KB Output is correct
16 Correct 279 ms 21836 KB Output is correct
17 Correct 285 ms 21964 KB Output is correct
18 Correct 281 ms 21908 KB Output is correct
19 Correct 280 ms 21200 KB Output is correct
20 Correct 286 ms 21580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 50 ms 428 KB Output is correct
4 Correct 49 ms 412 KB Output is correct
5 Correct 43 ms 348 KB Output is correct
6 Correct 48 ms 412 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 48 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 436 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 56 ms 408 KB Output is correct
14 Correct 47 ms 344 KB Output is correct
15 Correct 47 ms 428 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 6 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 59 ms 348 KB Output is correct
20 Correct 60 ms 592 KB Output is correct
21 Execution timed out 2073 ms 604 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 50 ms 428 KB Output is correct
4 Correct 49 ms 412 KB Output is correct
5 Correct 43 ms 348 KB Output is correct
6 Correct 48 ms 412 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 48 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 436 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 56 ms 408 KB Output is correct
14 Correct 47 ms 344 KB Output is correct
15 Correct 47 ms 428 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 6 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 59 ms 348 KB Output is correct
20 Correct 60 ms 592 KB Output is correct
21 Correct 308 ms 21268 KB Output is correct
22 Correct 308 ms 21332 KB Output is correct
23 Correct 311 ms 21456 KB Output is correct
24 Correct 308 ms 21328 KB Output is correct
25 Correct 312 ms 21308 KB Output is correct
26 Correct 290 ms 21256 KB Output is correct
27 Correct 283 ms 20840 KB Output is correct
28 Correct 288 ms 21072 KB Output is correct
29 Correct 299 ms 21380 KB Output is correct
30 Correct 308 ms 21352 KB Output is correct
31 Correct 266 ms 22448 KB Output is correct
32 Correct 270 ms 26224 KB Output is correct
33 Correct 266 ms 22392 KB Output is correct
34 Correct 292 ms 25024 KB Output is correct
35 Correct 269 ms 24948 KB Output is correct
36 Correct 279 ms 21836 KB Output is correct
37 Correct 285 ms 21964 KB Output is correct
38 Correct 281 ms 21908 KB Output is correct
39 Correct 280 ms 21200 KB Output is correct
40 Correct 286 ms 21580 KB Output is correct
41 Execution timed out 2073 ms 604 KB Time limit exceeded
42 Halted 0 ms 0 KB -