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;
#ifdef LOCAL
#include "C:\GCC\debug.h"
#else
#define debug(...) void(42)
#endif
vector<int> find_subset(int l, int u, vector<int> w) {
int n = (int) w.size();
cin >> n >> l >> u;
vector<pair<int, int>> a(n);
for (int i = 0 ; i < n ; i++) {
a[i].first = w[i];
a[i].second = i;
}
sort(a.begin(), a.end());
auto Exit = [&](int left, int right, int m) {
vector<int> res;
for (int i = left; i < right; i++) {
res.push_back(a[i].second);
}
return res;
};
int left = 0;
long long sum = 0;
for (int i = 0; i < n; i++) {
sum += 1ll * a[i].first;
while (sum > u) {
sum -= a[left++].first;
}
if (sum >= l && sum <= u) {
return Exit(left, i + 1, i + 1 - left);
}
}
if (sum >= l && sum <= u) {
return Exit(left, n, n - left);
}
vector<int> empt;
return empt;
}
# | 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... |