| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 498280 | OrazB | 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>
#define N 100005
#define ll long long int
#define pii pair <long long, long long>
#define pb push_back
#define ff first
#define ss second
using namespace std;
vector <int> find_subset(int l, int u, vector <int> w){
ll sm = 0, tr = 0, ls = 0, r = 0, md = 0;
vector <pii> v;
map <ll, ll> p;
vector <ll> ans;
for (int i = 0; i < w.size(); i++) v.pb({w[i], i});
sort (v.begin(), v.end());
for (int i = 0; i < v.size(); i++) p[i] = p[i - 1] + v[i].ff;
for (int i = 0; i < v.size(); i++){
ls = i; r = v.size()-1;
while (ls <= r){
md = (ls + r) / 2;
sm = p[md] - p[i - 1];
if (sm >= l and sm <= u){
for (int j = i; j <= md; j++) ans.pb(v[j].ss);
tr = 1; break;
}else if (sm > u) r = md - 1;
else ls = md + 1;
}
if (tr) break;
}
return ans;
}
