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;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<pair<int, int>> mol;
vector<int> ans;
int n = w.size();
for(int i = 0; i < n; i++)
mol.push_back({w[i],i});
sort(mol.begin(), mol.end());
int lo = 0, hi = 0;
long long sum = mol[0].first;
while(sum < l || sum > u){
if(sum < l){
if(hi < n-1){
hi++;
sum += mol[hi].first;
}else{
break;
}
}else if(sum > u){
if(lo < n-1){
sum -= mol[lo].first;
lo++;
}else{
break;
}
}
}
if(l <= sum && sum <= u){
for(int i = lo; i <= hi; i++)
ans.push_back(mol[i].second);
}
return ans;
}
# | 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... |