# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
853065 | _uros9 | 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>
#include "molecules.h"
#define endl '\n'
#define int long long
using namespace std;
const long long longlongmax=9223372036854775807;
const int modul=998244353;
const long long mod = 1e9 + 7;
vector<int> find_subset(int l,int u,vector<int> w){
int n=w.size();
vector<int> rez(0);
vector<pair<int,int>> niz(n);
for(int i=0; i<n; i++)
niz[i]={w[i],i};
sort(niz.begin(),niz.end());
if(niz[0].first>u) return rez;
vector<int> pref(n+1,0);
for(int i=0; i<n; i++){
pref[i+1]=pref[i];
pref[i+1]+=niz[i].first;
}
bool ok=false;
int ll,dd;
pref.push_back(1e15);
/*for(auto x:pref)
cout << x << " ";
cout << endl;*/
for(int i=0; i<n&&!ok; i++){
int ind=lower_bound(pref.begin(),pref.end(),pref[i]+l)-pref.begin();
//cout << pref[i] << " " << pref[ind] << endl;
if(pref[ind]-pref[i]>u) continue;
ok=true;
ll=i;
dd=ind;
}
if(!ok) return rez;
for(int i=ll; i<=dd-1; i++)
rez.push_back(niz[i].second);
return rez;
}