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;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = size(w);
vector<int> I(n); iota(begin(I),end(I),0);
sort(begin(I),end(I),[&](int x, int y) {
return w[x] > w[y];
});
int i, j = 0, k;
long long s = 0;
for (i = 0; i < n; ++i) {
k = I[i];
s += w[k];
if (s >= l) break;
}
while (true) {
if (s <= u) {
vector<int> res(i-j+1);
for (int x = j; x <= i; ++x)
res[x-j] = I[x];
return res;
}
if (i+1 == n) break;
s -= w[I[j++]], s += w[I[++i]];
}
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... |