# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101704 | coldEr66 | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 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>
using namespace std;
#include "molecules.h"
#define SZ(a) (int)a.size()
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<int> ret;
vector<pair<int,int> > tmp;
for (int i=0;i<SZ(w);i++) tmp.emplace_back(w[i],i);
sort(ALL(tmp));
long long sum = 0;
int L = 0, R = 0;
for (;L<SZ(w);L++) {
while (sum < l && R < SZ(w)) sum += tmp[i].X;
if (l <= sum && sum <= u) {
for (int i=L;i<=R;i++) ret.emplace(tmp[i].Y);
break;
}
if (L < R) sum -= w[L].X;
}
return ret;
}