답안 #886544

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886544 2023-12-12T09:53:15 Z vjudge1 Gym Badges (NOI22_gymbadges) C++17
0 / 100
2000 ms 6120 KB
#include <bits/stdc++.h>
using namespace std;
#define tol(bi) (1ll<<((int)(bi)))
int main(){
	int n;
	cin>>n;
	vector<pair<int,int>> arr(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i].second;
	}
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i].first;
	}
	sort(arr.begin(), arr.end(), [&](pair<int,int> a, pair<int,int> b){
		return (a.first+a.first)<(b.first+b.first);
	});
	vector<int> val(n+1,-1);
	val[0]=0;
	for (int i = 0; i < n; i++){
		//int upd = 0;
		for (int j = n-1; j >= 0; j--){
			if (val[j]==-1) continue;
			if (val[j]<=arr[i].first){
				//if (val[j+1]==-1 || val[j+1]>val[j]+arr[i].second)upd++;
				if (val[j+1]==-1) val[j+1]=val[j]+arr[i].second;
				val[j+1]=min(val[j+1],val[j]+arr[i].second);
			}
		}
		//cout<<upd<<endl;
	}
	for (int i = n; i >= 0; i--){
		if (val[i]!=-1){
			cout<<i<<endl;
			break;
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 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 Incorrect 0 ms 344 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2065 ms 6120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 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 Incorrect 0 ms 344 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 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 Incorrect 0 ms 344 KB Output isn't correct
9 Halted 0 ms 0 KB -