# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
673232 | Hacv16 | Jelly Flavours (IOI20_jelly) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "jelly.h"
using namespace std;
#define fr first
#define sc second
const int MAX = 2005;
const int INF = 0x3f3f3f3f;
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b){
int n = a.size();
vector<pair<int, int>> aux;
for(int i = 0; i < n; i++)
aux.emplace_back(a[i], b[i]);
sort(aux.begin(), aux.end());
vector<vector< pair<int, int> >> dp(n + 1, vector< pair<int, int> >(y + 1));
dp[0][0] = {0, x};
for(int t = 1; t <= y; t++)
dp[0][t] = {-INF, -INF};
int ans = 0;
for(int i = 1; i <= n; i++){
for(int j = 0; j <= y; j++){
dp[i][j] = dp[i - 1][j];
if(dp[i][j].sc >= a[i - 1]){
dp[i][j].fr++;
dp[i][j].sc -= a[i - 1];
}
if(j >= _b[i - 1]){
pair<int, int> tmp = dp[i - 1][j - b[i - 1]];
tmp.fr++;
if(tmp.fr > dp[i][j].fr || (tmp.fr == dp[i][j].fr && tmp.sc > dp[i][j].sc))
dp[i][j] = tmp;
}
ans = max(ans, dp[i][j].fr);
}
}
return ans;
}