# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
239413 | 2020-06-15T14:03:25 Z | GREGOIRELC | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KB |
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define int long long vector<int> find_subset(int l, int u, vector<int> val) { sort(val.begin(), val.end()); int deb = 0, fin = 0; int s = 0; while(fin < val.size() && s < l) { if(s + val[fin] > u) { s -= val[deb]; s += val[fin]; deb++; fin++; } else { s += val[fin]; deb++; fin++; } } vector<int> result; if(s < l || s > u) { return result; } for(int i = deb; i < fin; i++) { result.push_back(val[i]); } return result; }