# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
959278 | hyakup | 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"
using namespace std;
#define ll long long
vector<int> find_subset(int l, int r, vector<int> w ){
vector<pair<ll, int>> v( w.size() );
for( int i = 0; i < w.size(); i++ ) v[i] = make_pair(w[i], i);
sort( v.begin(), v.end());
vector<ll> sv(w.size() + 1), resp;
set<pair<ll, int>> s; s.insert({0, 0});
for( int i = 1; i <= sv.size(); i++ ){
sv[i] = sv[i - 1] + v[i - 1].first;
s.insert({ sv[i], i });
auto it = s.lower_bound({ sv[i] - (ll)r, -1});
if( it->first <= sv[i] - (ll)l ){
for( int j = it->second; j < i; j++ ) resp.push_back(v[j].second);
break;
}
}
return resp;
}