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>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define float long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n=sz(w);
vector<int> idx(n);
iota(all(idx),0);
sort(all(idx),[&w](int a,int b)->bool{
return w[a]<w[b];
});
int L=0,R=0;
ll sum=w[idx[0]];
while(L<n && R<n && L<=R){
if(l<=sum && sum<=u) return vector<int>(idx.begin()+L,idx.begin()+R+1);
if(sum<=l && R+1<n) sum+=w[idx[R+1]],R++;
else sum-=w[idx[L]],L++;
}
return {};
}
# | 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... |