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<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int) (x).size())
using namespace std;
int N;
vector<int> v1, v2;
vector<vector<vector<int>>> memo;
int f(int ind, int b1, int b2){
if(ind == N){
return 0;
}
if(memo[ind][b1][b2] != -1){
return memo[ind][b1][b2];
}
int ans = 0;
if(b1 >= v1[ind]){
ans = max(ans, f(ind + 1, b1 - v1[ind], b2) + 1);
}
if(b2 >= v2[ind]){
ans = max(ans, f(ind + 1, b1, b2 - v2[ind]) + 1);
}
ans = max(ans, f(ind + 1, b1, b2));
memo[ind][b1][b2] = ans;
return ans;
}
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
v1 = a;
v2 = b;
N = SZ(v1);
memo.resize(N);
for(int i = 0; i < N; i++){
memo[i].resize(x+1);
for(int j = 0; j <= x; j++){
memo[i][j].resize(y+1);
for(int k = 0; k <= y; k++)
memo[i][j][k] = -1;
}
}
return f(0, x, y);
}
# | 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... |