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>
std::vector<int> find_subset(int l, int u, std::vector<int> w)
{
std::vector<std::pair<int,int>> v;
int n=w.size();
for(int i=0;i<n;i++)
v.push_back({w[i],i});
std::sort(v.begin(),v.end());
std::vector<int> answer;
bool arr[222222];
int left=0,right=0;
long long sum=0;
bool possible=true;
while(left<=right)
{
if(sum<l)
{
if(right>=n)
{
possible=false;
break;
}
sum+=v[right].first;
arr[v[right].second]=true;
right++;
}
else if(sum>u)
{
sum-=v[left].first;
arr[v[left].second]=false;
left++;
}
else
break;
}
if(!possible)
return std::vector<int>(0);
for(int i=1;i<=n;i++)
if(arr[i])
answer.push_back(i);
return answer;
}
# | 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... |