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;
// #define int long long
vector<int> find_subset(int l, int r, vector<int> w){
int n = w.size();
vector<pair<int, int>> v(n);
for(int i = 0; i < n; i++){
v[i]={w[i], i};
}
sort(v.begin(), v.end());
queue<pair<int, int>> sol;
int aux = 0;
for(int i = 0; i < n; i++){
if(v[i].first > r) break;
while(aux+v[i].first > r){
aux-=sol.front().first;
sol.pop();
}
aux+=v[i].first;
sol.push(v[i]);
if(aux >= l) break;
}
if(aux < l || aux > r){
while(sol.size()) sol.pop();
}
vector<int> ans;
while(sol.size()){
ans.push_back(sol.front().second);
sol.pop();
}
// if(ans.size()) reverse(ans.begin(), ans.end());
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... |