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 <cassert>
#include <numeric>
using i64 = int64_t;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = w.size();
std::vector<int> ord(n);
std::iota(ord.begin(), ord.end(), 0);
std::sort(ord.begin(), ord.end(), [&](int x, int y) { return w[x] < w[y]; });
std::sort(w.begin(), w.end());
int k = 1;
for (i64 mn = 0, mx = 0; k <= n; ++k) {
mn += w[k - 1];
mx += w[n - k];
if (l <= mx && mn <= u) break;
}
if (k > n) return {};
auto cur = std::accumulate(w.begin(), w.begin() + k, i64(0));
for (int i = 0; i <= n - k; ++i) {
if (l <= cur && cur <= u) return {ord.begin() + i, ord.begin() + i + k};
cur -= w[i];
cur += w[i + k];
}
assert(false);
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... |