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>
std::vector <int> find_subset(int f, 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 l = 0, r = 0; r < n; r++) {
sum += a[r].first;
while (l <= r && sum > u) {
sum -= a[l++].first;
}
if (l > r) {
break;
}
if (sum >= f && sum <= u) {
std::vector <int> ans;
for (int j = l; j <= r; j++) {
ans.push_back(a[j].second);
}
return ans;
}
}
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... |