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;
typedef long long ll;
vector<int> find_subset(int L,int R,vector<int> w)
{
int n=w.size();
vector<array<int,2>> a(n);
for(int i=0;i<n;i++) a[i]={w[i],i};
sort(a.begin(),a.end());
int c=0;
ll s=0;
while(c<n&&s<L)
{
c++;
s+=a[n-c][0];
}
if(s<L) return {};
ll t=0;
for(int i=0;i<c;i++) t+=a[i][0];
if(t>R) return {};
int d=0;
while(s>R)
{
s+=a[d][0];
s-=a[n-1-d][0];
d++;
}
assert(L<=s&&s<=R);
vector<int> res;
for(int i=0;i<d;i++) res.push_back(a[i][1]);
for(int i=0;i<c-d;i++) res.push_back(a[n-1-i][1]);
return res;
}
# | 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... |