이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "jelly.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 10;
const int MAXM = 1e4 + 10;
int dp[MAXN][MAXM];
int calc(int i, int x, int y, int N, vector<int> &a, vector<int> &b)
{
if(x < 0 || y < 0) return -1;
if(dp[i][y] != -1) return dp[i][y];
if(i > N) return 0;
int op1;
if(x - a[i - 1] >= 0)
op1 = calc(i + 1, x - a[i - 1], y, N, a, b) + 1;
else
op1 = calc(i + 1, x, y, N, a, b);
int op2 = calc(i + 1, x, y - b[i - 1], N , a, b) + 1;
dp[i][y] = max(op1,op2);
return dp[i][y];
}
bool cmp(pair<int,int> a, pair<int,int> b)
{
if(a.first == b.first) return a.second < b.second;
return a.first < b.first;
}
int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
int N = a.size();
vector<pair<int,int>> aux;
for(int i = 0; i < N; i++)
aux.push_back({a[i],b[i]});
for(int i = 0; i <= N + 2; i++)
{
for(int j = 0; j <= y + 2; j++)
dp[i][j] = -1;
}
a.clear();
b.clear();
sort(aux.begin(),aux.end(),cmp);
for(int i = 0; i < N; i++)
{
a.push_back(aux[i].first);
b.push_back(aux[i].second);
}
return calc(1,x,y,N,a,b);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |