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>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
int size = w.size();
vector<pair<int,int>> p(size);
for(int i=0;i<size;i++)p[i]={w[i], i};
sort(p.begin(), p.end());
int left=0,right=0;
long long sum=p[0].first;
while(left<size||right<size){
if(sum<l){
right++;
if(right>=size) break;
sum+=p[right].first;
} else if(sum>u){
if(left>=size) break;
sum-=p[left].first;
left++;
}
else break;
}
if(l<=sum&&sum<=u){
vector<int> ans;
for(int i=left;i<=right;i++) ans.push_back(p[i].second);
return ans;
}
else 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... |