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 <bits/stdc++.h>
using namespace std;
const int MAXN = 2005, MAX = 1e4+5;
int dp[MAXN][MAX], dp2[MAXN][MAX];
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
int n = a.size();
sort(a.begin(),a.end());
int ans = 0;
for(int i = 0; i <= n; i++){
for(int k = 0; k <= x; k++)dp[i+1][k] = 0;
for(int j = i; j >= 1; j--)
for(int k = 0; k <= x; k++){
if(k < a[j-1])dp[j][k] = dp[j+1][k]+b[j-1];
else dp[j][k] = min(dp[j+1][k]+b[j-1], dp[j+1][k-a[j-1]]);
}
if(y < dp[1][x])continue;
int r = y - dp[1][x];
for(int j = n; j >= i+1; j--)
for(int k = 0; k <= r; k++){
if(k < b[j-1])dp2[j][k] = dp2[j+1][k];
else dp2[j][k] = max(dp2[j+1][k], dp2[j+1][k-b[j-1]]+1);
}
ans = max(i+dp2[i+1][r], ans);
}
return ans;
}
# | 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... |