// Karusia + Miki 2025 (totalnie)
#include <bits/stdc++.h>
using namespace std;
int dp[2000], bpa[10001], bpb[10001], sb[2000];
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
int n = a.size(), odp = 0;
pair<int,int> risa[n];
for (int i = 0; i < n; i++)
risa[i].first = a[i], risa[i].second = b[i];
sort(risa,risa+n), sb[0] = risa[0].second;
for (int i = 1; i < n; i++)
sb[i] = sb[i-1]+risa[i].second;
for (int i = 0; i < n; i++) {
dp[i] = -1000000000;
for (int j = x; j >= risa[i].first; j--)
bpa[j] = max(bpa[j],bpa[j-risa[i].first]+risa[i].second);
for (int j = 0; j <= x; j++)
dp[i] = max(dp[i],y-sb[i]+bpa[j]);
}
for (int i = n-1; i >= 0; i--) {
for (int j = y; j >= risa[i].second; j--)
bpb[j] = max(bpb[j],bpb[i-risa[i].second]+1);
if (i > 0 && dp[i-1] >= 0) {
for (int j = 0; j <= min(dp[i-1],y); j++)
odp = max(odp,i+bpb[j]);
}
}
if (dp[n-1] >= 0)
odp = n;
for (int i = 0; i <= y; i++)
odp = max(odp,bpb[i]);
return odp;
}
# | 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... |