# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
527002 | lcs147 | Detecting Molecules (IOI16_molecules) | C++98 | 1 ms | 296 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 r, vector<int> w) {
if(l > r) return {};
vector<int>id(w.size());
iota(id.begin(), id.end(), 0);
sort(id.begin(), id.end(), [&](int a, int b){
return w[a] < w[b];
});
while(id.size() && w[id.back()] > r) id.pop_back();
int sum = 0;
vector<int>has_sum(r+1, -1);
int en = -1;
while(1) {
if(sum != 0) {
while(sum <= r && has_sum[sum]==-1) sum++;
}
if(sum > r) return {};
if(sum >= l) {
en = sum;
break;
}
for(int i = has_sum[sum]+1; i<id.size(); i++) {
int nsum = sum + w[id[i]];
if(nsum > r) break;
has_sum[nsum] = i;
}
sum++;
}
sum = en;
vector<int>res;
while(sum > 0) {
int rid = id[has_sum[sum]];
res.push_back(rid);
sum -= w[rid];
}
sort(res.begin(), res.end());
return res;
}
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... |