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 = (int) a.size();
vector<pair<int, int>> jellies(n);
for (int i = 0; i < n; i++) {
jellies[i].first = a[i];
jellies[i].second = b[i];
}
sort(jellies.begin(), jellies.end());
int res = 0;
for (int i = 0; i < n; i++) {
int sum = 0;
for (int j = i; j < n; j++) {
if (sum + jellies[j].first > x) {
break;
}
sum += jellies[j].first;
int cur = j - i + 1;
vector<int> rem;
for (int k = 0; k < n; k++) {
if (k >= i && k <= j) {
continue;
}
rem.push_back(jellies[k].second);
}
sort(rem.begin(), rem.end());
int tmp = y;
for (int& cost : rem) {
if (tmp - cost >= 0) {
tmp -= cost;
++cur;
}
}
res = max(res, cur);
}
}
return res;
}
# | 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... |