Submission #886439

# Submission time Handle Problem Language Result Execution time Memory
886439 2023-12-12T07:09:06 Z vjudge1 Gym Badges (NOI22_gymbadges) C++17
0 / 100
2000 ms 16840 KB
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,abm,mmx,sse4.2,fma,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;

#define int uint64_t
#define PB push_back
#define sqr(a) ((a)*(a))
#define I insert
#define F first
#define S second

bool cmp(pair<int,int> const&a, pair<int,int> const&b) {
	return make_pair(a.S, a.F) < make_pair(b.S, b.F);
}

int32_t main() {
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin>>n;
	vector<pair<int,int>> a(n);
	for(int i=0; i<n; i++) cin>>a[i].S;
	for(int i=0; i<n; i++) cin>>a[i].F;
	sort(a.begin(), a.end());
	/* if(a[0].F==a[n-1].F) { */
	/* 	sort(a.begin(), a.end(), cmp); */
	/* 	int ans = 0, cur = 0; */
	/* 	for(int i=0; i<n; i++) { */
	/* 		if(cur <= a[0].F) { */
	/* 			cur += a[i].S; */
	/* 			ans++; */
	/* 		} */
	/* 		else { */
	/* 			cout<<ans<<'\n'; */
	/* 			return 0; */
	/* 		} */
	/* 	} */
	/* 	cout<<ans<<'\n'; */
	/* 	return 0; */
	/* } */
	vector<int> dp(n+1, UINT64_MAX);
	dp[0] = 0;
	for(int i=0; i<n; i++) {
		for(int j=n; j>0; j--) {
			dp[j] = min((dp[j-1]<=a[i].F)?(dp[j-1] + a[i].S):UINT64_MAX, dp[j]);
		}
	}
	for(int i=n; i>=0; i--) {
		if(dp[i]!=UINT64_MAX){
			cout<<i<<'\n';
			break;
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 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 344 KB Output is correct
7 Correct 0 ms 452 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2029 ms 16840 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 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 344 KB Output is correct
7 Correct 0 ms 452 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 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 344 KB Output is correct
7 Correct 0 ms 452 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -