# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1001886 | rahidilbayramli | Detecting Molecules (IOI16_molecules) | C++17 | 36 ms | 5584 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;
vi find_subset(int l, int u, vi w) {
int f = min(l, u);
int g = max(l, u);
l = f, u = g;
vi ans;
vector<pii>vect;
for(int i = 0; i < w.size(); i++)
vect.pb({w[i], i});
sort(rall(vect));
int tl = 0, tr = 0;
ll sum = 0;
while(tl < vect.size())
{
while(tr < vect.size() && sum + vect[tr].f <= u)
{
sum += (ll)(vect[tr].f);
tr++;
if(l <= sum && sum <= u)
{
for(ll j = tl; j < tr; j++)
ans.pb(vect[j].s);
return ans;
}
}
if(l <= sum && sum <= u)
{
for(ll j = tl; j < tr; j++)
ans.pb(vect[j].s);
return ans;
}
sum -= (ll)(vect[tl].f);
tl++;
}
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... |