# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
707566 | Error42 | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 288 KiB |
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 <numeric>
#include <vector>
using namespace std;
using ll = long long;
vector<int> find_subset(
int const l,
int const u,
vector<int> _w
) {
sort(_w.begin(), _w.end());
vector<ll> const w(_w.begin(), _w.end());
vector<ll> prefix(w.size() + 1);
partial_sum(w.begin(), w.end(), prefix.begin() + 1);
for (int mol_count = 1; mol_count <= w.size(); mol_count++) {
int lo = 0;
int hi = mol_count;
while (lo <= hi) {
int const mi = (lo + hi) / 2;
int const top = mi;
int const bottom = mol_count - mi;
ll val = prefix[bottom] + prefix[w.size()] - prefix[w.size() - top];
if (l <= val && val <= u) {
vector<int> solution;
for (int i = 0; i < bottom; i++)
solution.push_back(i);
for (int i = w.size() - top; i < w.size(); i++)
solution.push_back(i);
return solution;
}
if (val < l)
lo = mi + 1;
else
hi = mi - 1;
}
}
return {};
}
Compilation message (stderr)
# | 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... |