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"
#define pb push_back
#define mp make_pair
#define INF LLONG_MAX
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<int> c;
vector<pair<ll,ll>> d;
vector<ll> e;
vector<pair<ll,ll>> e1;
int n=w.size();
e.resize(n+1,0);
for(int i=0;i<n;i++){
d.pb(mp(w[i],(ll)i));
}
sort(d.begin(),d.end());
for(int i=1;i<=n;i++){
e[i]=e[i-1]+d[i-1].first;
}
e1.pb(mp((ll)0,(ll)0));
for(int i=1;i<=n;i++){
auto it=upper_bound(e1.begin(),e1.end(),mp(e[i]-l,INF));
if(it!=e1.begin()){
--it;
pll p=*it;
if(e[i]-p.first<=u){
for(int j=p.second;j<i;j++){
c.pb(d[j].second);
}
break;
}
}
e1.pb(mp(e[i],(ll)i));
}
sort(c.begin(),c.end());
return c;
}
# | 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... |