# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1002072 | rahidilbayramli | Detecting Molecules (IOI16_molecules) | C++17 | 44 ms | 7472 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 "molecules.h"
#include<bits/stdc++.h>
#pragma GCC optimize("-O3")
#define ll int
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define f first
#define s second
#define pb push_back
#define p_b pop_back
using namespace std;
vl find_subset(ll l, ll u, vl w) {
ll f = min(l, u);
ll g = max(l, u);
l = f, u = g;
vl ans;
vector<pll>vect;
vect.pb({0, 0});
for(ll i = 0; i < w.size(); i++)
vect.pb({w[i], i});
sort(all(vect));
ll n = w.size(), i;
ll pref[n+5];
pref[0] = 0;
for(i = 1; i <= n; i++)
pref[i] = pref[i-1] + vect[i].f;
//for(i = 1; i <= n; i++)
//cout << vect[i].f << ' ' << vect[i].s << "\n";
for(i = 1; i <= n; i++)
{
ll lo = i, hi = n;
//cout << "i: " << i << "\n";
while(lo <= hi)
{
ll mid = (lo + hi) / 2;
ll sum = pref[mid] - pref[i-1];
//cout << "mid: " << mid << " sum: " << sum << "\n";
if(sum > u)
hi = mid - 1;
else if(sum < l)
lo = mid + 1;
else if(l <= sum && sum <= u)
{
for(ll j = i; j <= mid; j++)
ans.pb(vect[j].s);
return ans;
}
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |