#include "jelly.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define st first
#define nd second
#define pb push_back
const int MAXN = 2000;
const int MAXX = 10 * 1000;
int dp[MAXN + 1][MAXX + 1];
int minn[MAXN + 1];
vector<pii> v;
priority_queue<int> pq;
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
int n = int(a.size());
v.pb({-1, -1});
for (int i = 0; i < n; i ++) {
v.pb({a[i], b[i]});
}
sort(v.begin(), v.end());
for (int i = 1; i <= n; i ++) {
minn[i] = INT_MAX;
for (int j = 0; j <= x; j ++) {
dp[i][j] = dp[i - 1][j] + v[i].nd;
if (j >= v[i].st) {
dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i].st]);
}
minn[i] = min(minn[i], dp[i][j]);
//cout << i << ", " << j << ": " << dp[i][j] << "\n";
}
}
int wyn = 0;
for (int i = 0; i <= n; i ++) {
//cout << i << ": " << minn[i] << "\n";
if (minn[i] > y) {
continue;
}
while (!pq.empty()) {
pq.pop();
}
for (int j = i + 1; j <= n; j ++) {
pq.push(-v[j].nd);
}
int akt = y - minn[i];
int ile = 0;
while (!pq.empty() && akt + pq.top() >= 0) {
akt += pq.top();
pq.pop();
ile ++;
}
wyn = max(wyn, ile + i);
}
return wyn;
}
# | 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... |