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 <bits/stdc++.h>
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<size_t> id(w.size());
iota(id.begin(), id.end(), 0);
sort(id.begin(), id.end(), [&w](size_t a, size_t b) { return w[a] < w[b]; });
long long sum = 0;
size_t cnt = 0;
vector<int> res;
for (size_t i: id) {
if (sum + w[i] < l) {
sum += w[i];
++cnt;
res.push_back(i);
} else
break;
}
if (cnt == w.size() || cnt == 0)
return {};
cerr << cnt << '\n';
cerr << sum << '\n';
sum -= w[id.front()];
sum += w[id.back()];
if (sum < l || sum > u)
return {};
assert (l <= sum && sum <= u);
res.erase(res.begin());
res.push_back(id.back());
return res;
}
# | 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... |