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>id(n);
iota(id.begin(), id.end(), 0);
sort(id.begin(), id.end(), [&] (int i, int j) {
return w[i] < w[j];
});
if(w[id[0]]>u) return vector<int>(0);
vector<int>ret;
long long cur = 0;
int j = -1;
for(int i=0; i<n; ++i) {
ret.push_back(id[i]);
cur += w[id[i]];
if(cur>=l) {
if(cur>u) {
j = i;
break;
} else {
return ret;
}
}
}
if(j==-1) return vector<int>(0);
cur -= w[ret[0]];
//assert(cur >= l && cur <= u);
ret.erase(ret.begin());
return ret;
}
# | 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... |