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>
inline std::vector <int> make(const std::vector <std::pair <int, int>>& a, int l, int r) {
std::vector <int> res;
for (int i = l; i <= r; i++) {
res.push_back(a[i].second);
}
return res;
}
std::vector <int> find_subset(int l, int u, std::vector <int> w) {
int n = w.size();
std::vector <std::pair <int, int>> a(n);
for (int i = 0; i < n; i++) {
a[i] = { w[i], i };
}
std::sort(a.begin(), a.end());
long long sum = 0;
for (int i = 0; i < n; i++) {
sum += a[i].first;
if (sum >= l && sum <= u) {
return make(a, 0, i);
}
if (sum > u) {
for (int j = 0; j < i; j++) {
sum -= a[j].first;
if (sum >= l && sum <= u) {
return make(a, j + 1, i);
}
}
break;
}
}
return { };
}
# | 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... |