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;
typedef long long ll;
vector<int> find_subset(int l, int u, vector<int>w)
{
ll n=w.size();
vector<pair<ll, int> >wv2(n+1);
for(int i=1; i<=n; i++){wv2[i]={w[i-1], i-1};}
sort(wv2.begin(), wv2.end());
vector<int>result;
long long sums[n+1];
sums[0]=(ll)0;
for(int i=1; i<=n; i++)sums[i]=(ll)wv2[i].first+sums[i-1];
for(int i=1, j=1; i<=n;)
{
ll sum=sums[i]-sums[j-1];
if(sum>=l and sum<=u)
{
for(int k=j; k<=i; k++)result.push_back(wv2[k].second);
break;
}
else if(sum<l)i++;
else if(sum>u)j++;
}
return result;
}
# | 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... |