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;
int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
int n = a.size();
if (n*x*y <= 5e7+100 and false) {
vector<vector<vector<int>>> dp(n+1, vector<vector<int>> (x+1, vector<int> (y+1, 0)));
for (int i=1; i<=n; i++) {
for (int xi=0; xi<=x; xi++) {
for (int yi=0; yi<=y; yi++) {
// não compra e pega o xi ou yi menor
dp[i][xi][yi] = max(0, dp[i][xi != 0 ? xi-1 : 0][yi]);
dp[i][xi][yi] = max(dp[i][xi][yi], dp[i][xi][yi != 0 ? yi-1 : 0]);
// não compra o i
dp[i][xi][yi] = max(dp[i][xi][yi], dp[i-1][xi][yi]);
// compra na a
if (xi >= a[i-1]) dp[i][xi][yi] = max(dp[i][xi][yi], dp[i-1][xi-a[i-1]][yi] + 1);
// compra na b
if (yi >= b[i-1]) dp[i][xi][yi] = max(dp[i][xi][yi], dp[i-1][xi][yi-b[i-1]] + 1);
}
}
}
return dp[n][x][y];
} else {
int cnt = 0, i=0;
sort(a.begin(), a.end());
for (; i<n; i++, cnt++) { // acha primeiro que não pode comprar
if (x < a[i]) break;
x -= a[i];
}
for (; i<n; i++, cnt++) {
if (y<b[i]) break;
y-=b[i];
}
return cnt;
}
}
# | 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... |