# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1010181 | Unlucky | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 348 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;
vector<int> find_subset(int l, int u, vector<int> w1) {
vector<pair<int, int>> w(w1.size());
for (int i = 0; i < w.size(); i++){
w[i] = {w1[i], i};
}
sort(w.begin(), w.end());
long long s = 0;
priority_queue<pair<int, int>> added;
int i = w.size()-1;
while (i >= 0 && s < l){
s += w[i].first;
added.push(w[i]);
i--;
}
if (s < l){
return vector<int>(0);
}
while (i >= 0 && s > u){
s -= added.top().first;
added.pop();
s += w[i].first;
added.push(w[i]);
i--;
}
if (s <= u && s >= l){
int n = added.size();
vector<int> ret(n);
for (int i = 0; i < n; i++){
ret[i] = added.top().second+1;
added.pop();
}
sort(ret.begin(), ret.end());
return ret;
}
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... |