This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "jelly.h"
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
vector<int> aa(2010), bb(2010);
int nn;
int memo[2020][510][510];
int dp(int x, int y, int i)
{
if(i == nn)return 0;
if(x <0 || y<0)return -1;
if(memo[i][x][y] != -1)return memo[i][x][y];
return memo[i][x][y]= max(dp(x-aa[i], y, i+1)+1, max(dp(x, y-bb[i], i+1)+1, dp(x, y, i+1)));
}
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
int n = a.size();
nn = n;
for(int i = 0; i<n; i++)
{
aa[i]=a[i];
bb[i]=b[i];
}
for(int i = 0; i<2010; i++)
for(int j = 0; j<510; j++)
for(int h = 0; h<510; h++)memo[i][j][h]=-1;
int c = 0;
c = dp(x, y, 0);
return c;
}
# | 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... |