# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
543385 | Blobo2_Blobo2 | Detecting Molecules (IOI16_molecules) | C++14 | 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>
#include "molecules.h"
//#include "grader.cpp"
using namespace std;
#define int long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define gen(arr,n,nxt) generate(arr,arr+n,nxt)
#define Blobo2 ios_base::sync_with_stdio(false);cin.tie(0);
vector<int> find_subset(int l, int u, vector<int> w) {
vector<pair<int,int> >v;
for(int i=0;i<(int)w.size();i++)v.push_back({w[i],i});
sort(all(v));
int cnt=0,s=0;
vector<int>ans;
for(int i=0;i<(int)v.size();i++){
cnt += v[i].first;
while(cnt > u){
cnt -= v[s].first;
s++;
}
if(cnt <=u && cnt>= l){
for(int j=s;j<=i;j++)ans.push_back(v[j].second);
break;
}
}
sort(all(ans));
return ans;
}