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 "molecules.h"
#include <algorithm>
#include <iostream>
#include <numeric>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> _w) {
const int N = _w.size();
vector<int> ids(N), w(N);
iota(ids.begin(), ids.end(), 0);
sort(ids.begin(), ids.end(), [&_w](const int a, const int b) {
return _w[a] < _w[b];
});
for (int i = 0; i < N; i++) {
w[i] = _w[ids[i]];
}
vector<int> ans;
long long sum = 0;
for (int i = 0; i < N && sum + w[i] <= u; i++) {
sum += w[i];
ans.push_back(ids[i]);
}
for (int i = 0; sum < l && i < (N - (int)ans.size()); i++) {
sum -= w[i];
sum += w[N-1-i];
ans[i] = ids[N-1-i];
}
if (sum < l) {
ans.clear();
}
return ans;
}
# | 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... |