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 <bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int r, vector<int> w) {
int n = w.size();
vector<int> order(n);
iota(order.begin(), order.end(), 0);
sort(order.begin(), order.end(), [&](int a, int b) {
return w[a] < w[b];
});
vector<long long> prefix(n + 1);
for (int i = 0; i < n; ++i) {
prefix[i + 1] = prefix[i] + w[order[i]];
}
for (int i = 1; i <= n; ++i) {
if (prefix[i] <= r && l <= prefix[n] - prefix[n - i]) {
for (int j = 0; j + i <= n; ++j) {
if (l <= prefix[j + i] - prefix[j] && prefix[j + i] - prefix[j] <= r) {
return vector<int>(order.begin() + j, order.begin() + j + i);
}
}
}
}
return vector<int>();
}
# | 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... |