# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
392186 | Hegdahl | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 208 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;
using ll = long long;
vector<int> find_subset(int _l, int _u, vector<int> w) {
ll l = _l, u = _u;
int n = w.size();
ll mn = 1LL<<60;
for (int v : w)
mn = min(mn, (ll)v);
if (mn > u) return {};
vector<int> idxs(n);
iota(idxs.begin(), idxs.end(), 0);
sort(idxs.begin(), idxs.end(), [&](int i, int j){ return w[i] < w[j]; });
ll s = 0;
vector<int> ans;
for (int _i = 0; _i < n; ++_i) {
int i = idxs[_i];
if (s + w[i] > u) {
break;
}
s += w[i];
ans.push_back(i);
if (s >= l) return ans;
}
int i = 0;
int d = n-ans.size();
while (i+d < n && i < ans.size()) {
s -= w[ans[i]];
ans[i] = idxs[i+d];
s += w[ans[i]];
++i;
if (s >= l) return ans;
}
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... |