# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1024170 | vanea | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 436 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 <bits/stdc++.h>
#include "molecules.h"
using namespace std;
using ll = long long;
vector<int> find_subset(int l, int u, vector<int> w) {
deque<int> ans;
vector<array<int, 2>> w1;
int n = w.size();
for(int i = 0; i < n; i++) {
w1.push_back({w[i], i});
}
sort(w1.begin(), w1.end());
int i = 0, j = 1;
ans.push_back(w1[0][1]);
ll curr = w1[0][0];
bool fnd = false;
while(i < n && j < n) {
if(curr >= l && curr <= u) {
fnd = true;
break;
}
else if(curr < l) {
curr += w1[j][0];
ans.push_back(w1[j][1]);
++j;
}
else if(curr > u) {
ans.pop_front();
curr -= w1[i][0];
++i;
}
}
if(fnd || curr >= l && curr <= u) {
vector<int> res;
while(!ans.empty()) {
auto node = ans.front();
ans.pop_front();
res.push_back(node);
}
sort(res.begin(), res.end());
return res;
}
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... |