# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
134983 | 2019-07-23T13:45:52 Z | antimirage | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KB |
#include "molecules.h" #include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define all(s) s.begin(), s.end() #define int long long using namespace std; vector <int> ans; vector <pair <int, int> > w; vector<int> find_subset(int l, int r, vector<int> asd) { int j = 0, sum = 0; for (int i = 0; i < (int)asd.size(); i++) { w.pb({asd[i], i}); } sort(all(w)); for (int i = 0; i < (int)w.size(); i++) { sum += w[i].fr; while (j <= i && sum > r) { sum -= w[j].fr; j++; } if (sum >= l && sum <= r) { for (int k = j; k <= i; k++) { ans.pb(w[k].sc); } return ans; } } return ans; }