# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
875743 | raul2008487 | 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 ll int
#define pb push_back
#define vl vector<ll>
using namespace std;
bool check(ll cur, ll low, ll high){
return (cur <= high && cur >= low);
}
vector<int> find_subset(int l, int u, vector<int> w) {
vl ans;
ll i, j, n = w.size(), l = 0, r = 1, sum = w[0];
sort(all(w));
bool as = 0;
while(r <= w.size()){
if(check(sum, l, u)){
for(i=l+1;i<=r;i++){
ans.pb(i);
as = 1;
break;
}
}
else if(sum > u){
l++;
sum -= w[l-1];
}
else{
r++;
sum += w[r-1];
}
}
return ans;
}