# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
683984 | Juan | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define ff first
#define ss second
vector<ll> find_subset(ll L, ll R, vector<ll> w){
ll n = w.size();
vector<pii> arr;
for(ll i = 0; i < n; i++) arr.push_back({w[i], i});
sort(arr.begin(), arr.end());
vector<ll> ans;
ll l=0, r=0, sum=0;
while(r<n){
if(sum<L) sum += arr[r++].ff;
if(sum>R) sum -= arr[l++].ff;
if(sum>=L && sum<=R){
for(ll i = l; i < r; i++) ans.push_back(arr[i].ss);
break;
}
}
return ans;
}