# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170127 | 2019-12-24T05:00:26 Z | buttercrab | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KB |
#include "molecules.h" using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pair<int, int>> v; for (int i = 0; i < n; i++) { v.emplace_back(w[i], i); } sort(v.begin(), v.end()); int s = 0, h = 0, t = 0; while (t < n) { while (t < n && s < l) { s += v[t].first; t++; } if (l <= s && s <= u) { vector<int> ans; for (int i = h; i < t; i++) ans.emplace_back(i); return ans; } while (h < t && s >= l) { s -= w[h]; h++; } } return vector<int>(); }