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>
//#include "molecules.h"
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w)
{
vector<pair<int,int>> vec;
vec.push_back({0,0});
int n=w.size();
for (int i=0;i<n;i++) vec.push_back({w[i],i});
sort(vec.begin(),vec.end());
int levo=1,desno=1,val=vec[1].first;
bool resenje=false;
while (true)
{
if (val>=l and val<=u) {resenje=true;break;}
if (val<l and desno<n) {desno++;val+=vec[desno].first;}
else if (val<l and desno==n) break;
else if (val>u and levo<desno) {val-=vec[levo].first;levo++;}
else if (val>u and levo==desno) break;
}
vector<int> ans;
if (!resenje) return ans;
for (int i=levo;i<=desno;i++) ans.push_back(vec[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... |