# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
265837 | 2020-08-15T05:00:09 Z | amalla | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KB |
#include "molecules.h" #include<bits/stdc++.h> using namespace std; #define ll long long vector<int> find_subset(int l, int u, vector<int> w) { int N = w.size(); vector<pair<int,int>> A(N); for (int i = 0; i<N; ++i) { A[i].first = w[i]; A[i].second = i; } sort(A.begin(), A.end()); ll sum = 0; queue<int> q; for (int i = 0; i<N; ++i) { sum += A[i].first; q.push(A[i].second); while (sum>u) { sum -= A[q.front()]; q.pop(); } if (sum>=l) { vector<int> Ans(q.size()); j = 0; while(!q.empty()) { Ans[j] = q.front(); q.pop(); ++j; } return Ans; } } return vector<int>(0); }