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;
vector<int> find_subset(int l, int u, vector<int> w) {
int n=w.size();
vector<pair<int,int> > wpos;
for (int i=0;i<n;i++){
wpos.push_back(make_pair(w[i],i));
}
sort(wpos.begin(),wpos.end());
int maxsize=0;
long long tempsum=0;
while (tempsum<=u && maxsize<n){
tempsum+=wpos[maxsize].first;
maxsize++;
}
if (tempsum>u) maxsize--;
deque<int> ans;
vector<int> temp;
long long sum=0;
for (int i=0;i<maxsize;i++){
ans.push_back(wpos[i].second);
sum+=wpos[i].first;
}
if (sum>=l){
vector<int> realans;
for (auto i:ans) realans.push_back(i);
return realans;
}
for (int i=maxsize;i<n;i++){
ans.push_back(wpos[i].second);
ans.pop_front();
sum-=wpos[i-maxsize].first;
sum+=wpos[i].first;
if (sum>=l){
vector<int> realans;
for (auto i:ans) realans.push_back(i);
return realans;
}
}
if (sum>=l){
vector<int> realans;
for (auto i:ans) realans.push_back(i);
return realans;
}
else return temp;
}
# | 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... |