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>
#include "molecules.h"
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<int> order(n);
iota(order.begin(), order.end(), 0);
sort(order.begin(), order.end(), [&](int a, int b) {
return w[a] < w[b];
});
int i = 0, j = 0;
long long sum = 0LL;
while (i < n && j < n) {
while (j < n && (i >= j || sum < l)) {
sum += w[order[j++]];
}
while (i + 1 < j && sum > u) {
sum -= w[order[i++]];
}
if (i < j && l <= sum && sum <= u) {
vector<int> ans;
for (int p = i; p < j; ++p) {
ans.emplace_back(order[p]);
}
return ans;
}
sum -= w[order[i++]];
}
return vector<int>();
}
# | 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... |