#include "jelly.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
vector<int> aprice;
vector<int> bprice;
int dp[501][501][12];
int knapsack(int x,int y,int ind){
if(dp[x][y][ind]!=-1)return dp[x][y][ind];
if(x-aprice[ind]>=0 && y-bprice[ind])dp[x][y][ind]=max(max(knapsack(x-aprice[ind],y,ind-1),knapsack(x,y-bprice[ind],ind-1))+1,knapsack(x,y,ind-1));
else if(x-aprice[ind]>=0)dp[x][y][ind]=max(knapsack(x-aprice[ind],y,ind-1)+1,knapsack(x,y,ind-1));
else if(y-bprice[ind]>=0)dp[x][y][ind]=max(knapsack(x,y-bprice[ind],ind-1)+1,knapsack(x,y,ind-1));
else dp[x][y][ind]=knapsack(x,y,ind-1);
return dp[x][y][ind];
}
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-1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
1st lines differ - on the 1st token, expected: '8', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
1st lines differ - on the 1st token, expected: '8', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
1st lines differ - on the 1st token, expected: '8', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |