#include "jelly.h"
#include <bits/stdc++.h>
using namespace std;
int dp[2][550][550];
int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
//
int n = a.size();
if (!y)
{
sort(a.begin(), a.end());
int ans = 0;
for (int i = 0; i < n; i++)
{
if (x < a[i])break;
ans++;
x -= a[i];
}
return ans;
}
else if (x <= 500 && y <= 500 && n <= 200)
{
for (int k = 0; k < n; k++)
{
int t = k % 2;
for (int i = 0; i <= x; i++)
{
for (int j = 0; j <= y; j++)
{
dp[t][i][j] = dp[!t][i][j];
}
}
for (int i = 0; i <= x; i++)
{
for (int j = 0; j <= y; j++)
{
if (i >= a[k])
{
dp[t][i][j] = max(dp[t][i][j], dp[!t][i - a[k]][j] + 1);
}
if (j >= b[k])
{
dp[t][i][j] = max(dp[t][i][j], dp[!t][i][j - b[k]] + 1);
}
}
}
}
int m = 0;
for (int i = 0; i <= x; i++)
{
for (int j = 0; j <= y; j++)
{
m = max(m, dp[0][i][j]);
m = max(m, dp[1][i][j]);
}
}
return m;
}
else
{
sort(a.begin(), a.end());
int ans = 0;
for (int i = 0; i < n; i++)
{
if (x < a[i])break;
ans++;
x -= a[i];
}
while (y >= b[0])
{
y -= b[0];
ans++;
}
return min(ans, 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... |