Submission #886532

# Submission time Handle Problem Language Result Execution time Memory
886532 2023-12-12T09:38:27 Z Kel_Mahmut Gym Badges (NOI22_gymbadges) C++17
24 / 100
2000 ms 26056 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;
	}

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 46 ms 348 KB Output is correct
4 Correct 44 ms 344 KB Output is correct
5 Correct 42 ms 348 KB Output is correct
6 Correct 49 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 56 ms 596 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 436 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 53 ms 348 KB Output is correct
14 Correct 47 ms 348 KB Output is correct
15 Correct 47 ms 348 KB Output is correct
16 Correct 5 ms 344 KB Output is correct
17 Correct 7 ms 500 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 59 ms 348 KB Output is correct
20 Correct 57 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 312 ms 21332 KB Output is correct
2 Correct 314 ms 21488 KB Output is correct
3 Correct 309 ms 21328 KB Output is correct
4 Correct 312 ms 21552 KB Output is correct
5 Correct 313 ms 21328 KB Output is correct
6 Correct 292 ms 21288 KB Output is correct
7 Correct 280 ms 20560 KB Output is correct
8 Correct 293 ms 21184 KB Output is correct
9 Correct 290 ms 21156 KB Output is correct
10 Correct 294 ms 21328 KB Output is correct
11 Correct 265 ms 22588 KB Output is correct
12 Correct 264 ms 24864 KB Output is correct
13 Correct 275 ms 22492 KB Output is correct
14 Correct 270 ms 26056 KB Output is correct
15 Correct 270 ms 25844 KB Output is correct
16 Correct 283 ms 21964 KB Output is correct
17 Correct 281 ms 21812 KB Output is correct
18 Correct 278 ms 21704 KB Output is correct
19 Correct 280 ms 21228 KB Output is correct
20 Correct 277 ms 21200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 46 ms 348 KB Output is correct
4 Correct 44 ms 344 KB Output is correct
5 Correct 42 ms 348 KB Output is correct
6 Correct 49 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 56 ms 596 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 436 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 53 ms 348 KB Output is correct
14 Correct 47 ms 348 KB Output is correct
15 Correct 47 ms 348 KB Output is correct
16 Correct 5 ms 344 KB Output is correct
17 Correct 7 ms 500 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 59 ms 348 KB Output is correct
20 Correct 57 ms 348 KB Output is correct
21 Execution timed out 2091 ms 600 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 46 ms 348 KB Output is correct
4 Correct 44 ms 344 KB Output is correct
5 Correct 42 ms 348 KB Output is correct
6 Correct 49 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 56 ms 596 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 436 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 53 ms 348 KB Output is correct
14 Correct 47 ms 348 KB Output is correct
15 Correct 47 ms 348 KB Output is correct
16 Correct 5 ms 344 KB Output is correct
17 Correct 7 ms 500 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 59 ms 348 KB Output is correct
20 Correct 57 ms 348 KB Output is correct
21 Correct 312 ms 21332 KB Output is correct
22 Correct 314 ms 21488 KB Output is correct
23 Correct 309 ms 21328 KB Output is correct
24 Correct 312 ms 21552 KB Output is correct
25 Correct 313 ms 21328 KB Output is correct
26 Correct 292 ms 21288 KB Output is correct
27 Correct 280 ms 20560 KB Output is correct
28 Correct 293 ms 21184 KB Output is correct
29 Correct 290 ms 21156 KB Output is correct
30 Correct 294 ms 21328 KB Output is correct
31 Correct 265 ms 22588 KB Output is correct
32 Correct 264 ms 24864 KB Output is correct
33 Correct 275 ms 22492 KB Output is correct
34 Correct 270 ms 26056 KB Output is correct
35 Correct 270 ms 25844 KB Output is correct
36 Correct 283 ms 21964 KB Output is correct
37 Correct 281 ms 21812 KB Output is correct
38 Correct 278 ms 21704 KB Output is correct
39 Correct 280 ms 21228 KB Output is correct
40 Correct 277 ms 21200 KB Output is correct
41 Execution timed out 2091 ms 600 KB Time limit exceeded
42 Halted 0 ms 0 KB -