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 ll long long
#define all(v) v.begin() , v.end()
#define sz(a) (ll)a.size()
using namespace std;
vector<int> find_subset(int _l, int _r, vector<int> w){
ll n=sz(w),l=_l,r=_r;
vector<ll> v(n);
for(int i=0;i<n;i++) v[i]=w[i];
vector<ll> ind(n,0LL);
iota(all(ind),0LL);
sort(all(ind),[&](int a,int b){
return v[a] < v[b];
});
ll cur = 0, p = 0;
deque<int> dq;
while(p<n){
dq.push_back(ind[p]);
cur+=v[ind[p++]];
if(cur<=r && cur>=l){
vector<int> ans;
for(int x:dq) ans.push_back(x);
sort(all(ans));
return ans;
}
if(cur<l) continue;
cur-=v[dq.front()];
dq.pop_front();
if(cur<=r && cur>=l){
vector<int> ans;
for(int x:dq) ans.push_back(x);
sort(all(ans));
return ans;
}
}
return {};
}
/*void _(){
int n,l,r;
cin >> n >> l >> r;
vector<int> v(n);
for(int i=0;i<n;i++) cin >> v[i];
vector<int> ind(n,0);
iota(all(ind),0);
sort(all(ind),[&](int a,int b){
return v[a] < v[b];
});
int cur = 0, p = 0;
deque<int> dq;
while(p<n){
dq.push_back(ind[p]);
cur+=v[ind[p++]];
if(cur<=r && cur>=l){
for(int x:dq) cout << x << ' ';
cout << '\n';
return;
}
if(cur<l) continue;
cur-=v[dq.front()];
dq.pop_front();
if(cur<=r && cur>=l){
for(int x:dq) cout << x << ' ';
cout << '\n';
return;
}
}
cout << -1 << '\n';
}
int32_t main(){
cin.tie(0); ios::sync_with_stdio(0);
int tc=1;//cin >> tc;
while(tc--) _();
return 0;
}*/
# | 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... |