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 int long long
vector<signed> find_subset(signed l, signed u, vector<signed> w) {
int n = w.size(), r = u;
vector<pair<int, int>> vec;
for (int i=0; i<n; i++) {
int k = w[i];
vec.push_back({k, i});
}
sort(vec.begin(), vec.end());
int mi = 0, ma = 0, li = 0, ri = n - 1;
while (li < n) {
mi += vec[li].first, ma += vec[ri].first;
if (l <= mi && mi <= r) {
vector<signed> ans;
for (int i=0; i<=li; i++) ans.push_back(vec[i].second);
return ans;
}
if (l <= ma && ma <= r) {
vector<signed> ans;
for (int i=ri; i<n; i++) ans.push_back(vec[i].second);
return ans;
}
if (mi <= l && r <= ma) {
int sum = mi - vec[li].first;
for (int i=li; i<n; i++) {
sum += vec[i].first;
if (l <= sum && sum <= r) {
vector<signed> ans;
for (int j=i-li; j<=i; j++) ans.push_back(vec[j].second);
return ans;
}
sum -= vec[i-li].first;
}
}
li++, ri--;
}
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... |