제출 #986145

#제출 시각아이디문제언어결과실행 시간메모리
986145SofiatpcJelly Flavours (IOI20_jelly)C++14
10 / 100
72 ms156644 KiB
#include "jelly.h"
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAXN = 2005, MAX = 1e4+5;
int dp[MAXN][MAX], dp2[MAXN][MAX];
 
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
	int n = a.size();
 
	sort(a.begin(),a.end());
	int ans = 0; 
	for(int j = 1; j <= n; j++)
		for(int k = 0; k <= x; k++){
			if(k < a[j-1])dp[j][k] = dp[j-1][k]+b[j-1];
			else dp[j][k] = min(dp[j-1][k]+b[j-1], dp[j-1][k-a[j-1]]);
		}

	for(int j = n; j >= 1; j--)
		for(int k = 0; k <= y; k++){
			if(k < b[j-1])dp2[j][k] = dp2[j+1][k];
			else dp2[j][k] = max(dp2[j+1][k], dp2[j+1][k-b[j-1]]+1);
		}


	for(int i = 0; i <= n; i++){
		if(y < dp[i][x])continue;
		int r = y - dp[i][x];
		ans = max(i+dp2[i+1][r], ans);
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...