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>
//#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define sc second
//#define endl "\n"
#define pii pair<int,int>
using namespace std;
const int MAXN = 1e5+5;
const int mod7 = 1e9+7;
const long long inf = 1e18;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = w.size();
vector<pii> niz(n);
for(int i=0; i<n; i++)niz[i] = mp(w[i],i);
sort(all(niz));
int pl = 0;
int pr = 0;
long long trsum = 0;
vector<int> resenje;
while(pr< n)
{
trsum+= niz[pr].fi;
if(trsum <= u && trsum>=l)
{
for(int i=pl; i<=pr; i++)resenje.pb(niz[i].sc);
return resenje;
}
if(trsum >= u)
{
if(pl == n-1)break;
trsum-=niz[pl++].fi;
if(pl > pr)
{
pr++;
if(pr >= n)break;
trsum+=niz[pr].fi;
}
if(trsum <= u && trsum>=l)
{
for(int i=pl; i<=pr; i++)resenje.pb(niz[i].sc);
return resenje;
}
}
else pr++;
}
return resenje;
}
# | 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... |