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 <algorithm>
#include <cstdint>
#include <numeric>
#include <vector>
#include "molecules.h"
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
std::vector<uint32_t> p(w.size());
iota(p.begin(), p.end(), 0);
sort(p.begin(), p.end(), [&](auto a, auto b) { return w[a] < w[b]; });
int T{};
std::vector<int> S{};
size_t i{};
while (i < p.size() && T + w[p[i]] <= u) {
T += w[p[i]];
S.push_back(p[i]);
++i;
}
if (S.size() == 0) return {};
while (i < p.size() && T < l) {
T += w[p[i]] - w[S[i % S.size()]];
S[i % S.size()] = p[i];
++i;
}
return l <= T && T <= u ? S : std::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... |