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;
#define ll long long
#define pll pair<ll, ll>
vector<int> getans(int l, int r, vector<pll> w) {
vector<int> a;
for (int i = l; i < r; i++) {
a.push_back(w[i].second);
}
return a;
}
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<pll> arr;
for (int i = 0; i < n; i++) {
arr.push_back({w[i], i});
}
sort(arr.begin(), arr.end());
int le = 0, r = 0;
ll currSum = 0;
while (r < n) {
while (currSum < l && r < n) {
currSum += arr[r++].first;
}
while (currSum > u && le < r) {
currSum -= arr[le++].first;
}
if (currSum >= l && currSum <= u) {
return getans(le, r, arr);
}
if (r < n) currSum += arr[r++].first;
}
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... |