답안 #949592

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949592 2024-03-19T11:42:49 Z tnun Jelly Flavours (IOI20_jelly) C++14
0 / 100
38 ms 78428 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
pair<int,int> c[2005];
int dp[2005][10005];
int find_maximum_unique(int x, int y,vector<int> a,vector<int> b){
	int sz=a.size();
	int ans=0;
	for(int i=0;i<sz;i++){
		c[i+1]=mp(a[i],b[i]);
	}
	sort(c+1,c+sz+1);
	for(int i=1;i<=sz;i++){
		int uld=10005;
		for(int j=0;j<=x;j++){
			dp[i][j]=dp[i-1][j]+c[i].second;
			if(j>=c[i].first){
				dp[i][j]=min(dp[i][j],dp[i][j-c[i].first]);
			}
			uld=min(uld,dp[i][j]);
		}
		uld=y-uld;
		if(uld<0){
			continue;
		}
		int cnt=i;
		vector<int> temp;
		for(int k=i+1;k<=sz;k++){
			temp.pb(c[k].second);
		}
		sort(temp.begin(),temp.end());
		for(int k=0;k<temp.size();k++){
			if(uld>=temp[k]){
				uld-=temp[k];
				cnt++;
			}else{
				break;
			}
		}
		ans=max(cnt,ans);
		
	}
	return ans;
}

Compilation message

jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:34:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for(int k=0;k<temp.size();k++){
      |               ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB 1st lines differ - on the 1st token, expected: '8', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB 1st lines differ - on the 1st token, expected: '8', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 78428 KB 1st lines differ - on the 1st token, expected: '689', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 76660 KB 1st lines differ - on the 1st token, expected: '62', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 78420 KB 1st lines differ - on the 1st token, expected: '154', found: '49'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB 1st lines differ - on the 1st token, expected: '8', found: '4'
2 Halted 0 ms 0 KB -