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