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;
vector<int> find_subset(int l, int u, vector<int> w)
{
int n=w.size();
vector<int> ans;
vector<pair<int,int> > a;
for (int i=0;i<n;i++)
a.push_back({w[i],i});
sort(a.begin(),a.end());
long long L=0,R=0,sum=a[0].first;
for (int i=1;i<n;i++)
{
if (sum+a[i].first<=u)
{
sum+=a[i].first;
R=i;
}
}
for (int i=R+1;i<n;i++)
{
if (sum>=l && sum<=u)
{
for (int j=L;j<=R;j++)
ans.push_back(a[j].second);
return ans;
}
sum-=a[L].first;
L++;
R++;
sum+=a[R].first;
}
if (sum>=l && sum<=u)
{
for (int j=L;j<=R;j++)
ans.push_back(a[j].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... |