# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
551019 | Sergio_2357 | Detecting Molecules (IOI16_molecules) | C++17 | 62 ms | 10400 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
std::vector<int> find_subset(int l, int u, vector<int> w)
{
ll sum = 0;
vector<ll> a(w.size());
for (int i = 0; i < w.size(); i++)
a[i] = w[i];
ll n = a.size();
vector<ll> us(n, 0);
vector<pair<ll, ll>> ri(n);
for (int i = 0; i < n; i++)
ri[i] = { w[i], i };
sort(a.begin(), a.end());
sort(ri.begin(), ri.end());
ll s = 0;
ll e = n - 1;
while (sum < l && e >= 0) {
us[e] = 1;
sum += a[e];
e--;
//cout << sum << endl;
}
e = n - 1;
while (sum > u && s < e) {
if (!us[e] || us[s])
break;
us[e] = 0;
us[s] = 1;
sum -= a[e];
sum += a[s];
e--;
s++;
//cout << sum << endl;
}
if (sum >= l && sum <= u) {
vector<int> res;
for (int i = 0; i < n; i++) {
if (us[i])
res.push_back(ri[i].second);
}
sort(res.begin(), res.end());
return res;
} else {
return vector<int>(0);
}
}
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... |