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;
vector<int> find_subset(int l0, int r0, vector<int> aa) {
int n = (int) aa.size();
long long l1 = 0, r1 = 0;
vector<int> ii(n);
for (int i = 0; i < n; i++)
ii[i] = i;
sort(ii.begin(), ii.end(), [&](int i, int j) {
return aa[i] < aa[j];
});
for (int k = 1; k <= n; k++) {
l1 += aa[k - 1], r1 += aa[n - k];
if (l1 <= r0 && r1 >= l0) {
vector<int> ans; int sum = 0;
for (int i = 0; i < k; i++)
ans.push_back(ii[i]), sum += aa[ii[i]];
for (int i = 0; i < k && sum < l0; i++)
ans[i] = ii[n - i - 1], sum += aa[ans[i]] - aa[ii[i]];
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... |