This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* input
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
vector<int> find_subset(int l, int r, vector<int> w) {
int n = w.size();
pair<int, int> a[n + 1];
for (int i = 0; i < n; ++i) a[i] = make_pair(w[i], i);
sort (a, a + n);
ll cur = 0; deque<int> ans;
int R = n - 1;
for (; ~R; --R) {
cur += a[R].first; ans.push_back(a[R].second);
if (cur >= l && cur <= r) {
vector<int> ret;
for (int i : ans) ret.push_back(i);
return ret;
}
if (cur >= r) break;
}
int L = 0;
while (L < ans.back() && cur > r) {
cur -= w[ans.back()]; ans.pop_back();
cur += a[L].first; ans.push_front(a[L++].second);
}
if (cur > r) return vector<int>(0);
vector<int> ret;
for (int i : ans) ret.push_back(i);
return ret;
}
# | 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... |