# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1062616 | 2024-08-17T09:07:07 Z | TsotneSV | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KB |
#pragma once #include <bits/stdc++.h> using namespace std; /* /\_/\ (= ._.) / > \> */ #define fi first #define se second vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); pair<int,int> A[n]; for(int i=0;i<n;i++) A[i] = {w[i],i}; sort(A,A+n); int lo = 0,hi = 0; ll sum = 0; while(hi < n) { sum += A[hi++].fi; while(lo < hi-1 and sum > u) sum -= A[lo++].fi; if(sum >= l) { vector<int> ret(hi - lo); for(int i=lo;i<hi;i++) ret[i-lo] = A[i].se; return ret; } } return vector<int>(0); }