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<bits/stdc++.h>
using namespace std;
vector<int> aprice;
vector<int> bprice;
int knapsack(int x,int y,int ind){
if(ind==0 || (x==0 && y==0))return 0;
if(x-aprice[ind-1]>=0 && y-bprice[ind-1]>=0){
return max(max(knapsack(x-aprice[ind-1],y,ind-1),knapsack(x,y-bprice[ind-1],ind-1))+1,knapsack(x,y,ind-1));
}
else if(x-aprice[ind-1]>=0){
return max(knapsack(x-aprice[ind-1],y,ind-1)+1,knapsack(x,y,ind-1));
}
else if(y-bprice[ind-1]>=0){
return max(knapsack(x,y-bprice[ind-1],ind-1)+1,knapsack(x,y,ind-1));
}
else return knapsack(x,y,ind-1);
}
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
int n = a.size();
aprice=a;
bprice=b;
return knapsack(x,y,n);
}
# | 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... |