# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
413850 | illyakr | Detecting Molecules (IOI16_molecules) | C++14 | 105 ms | 19600 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 <bits/stdc++.h>
using namespace std;
#define ll long long
vector<pair<ll, ll> > a;
multiset<pair<ll, ll> > ok, bad;
ll now = 0;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
for (ll i = 0; i < w.size(); i++)
a.push_back({w[i], i});
sort(a.begin(), a.end(), [](pair<ll, ll> q, pair<ll, ll> w) {
return q.first < w.first;
});
for (auto [i, j] : a) {
if (now + i <= u) {
now += i;
ok.insert({i, j});
} else {
bad.insert({i, j});
}
}
while (true) {
if (l <= now && now <= u) {
vector<int> res;
for (auto [i, j] : ok)
res.push_back(j);
return res;
}
if (bad.empty() || ok.empty())break;
auto have = *ok.begin();
auto want = *(--bad.end());
ok.erase(ok.begin());
bad.erase(--bad.end());
if (have.first >= want.first)break;
now -= have.first;
now += want.first;
ok.insert(want);
}
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... |