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>
using namespace std;
vector <int> find_subset(int l , int u , vector <int> w)
{
vector <int> t = w;
int r = u;
vector <pair<int ,int>> ar;
int n = t.size();
for(int i = 0 ; i < n ; i++)
ar.push_back({t[i] , i});
sort(ar.begin() , ar.end());
vector <int> res;
int num = 0;
long long sum = 0;
for(int i = n - 1 ; i > -1 ; i--)
{
sum += ar[i].first;
num++;
if(sum >= l)
break;
}
num--;
if(sum < l)
return res;
long long sum2 = 0;
for(int i = 0 ; i <= num ; i++)
sum2 += ar[i].first;
if(sum2 > r)
return res;
int las = n - 1;
while(sum2 < l)
{
sum2 += (ar[las].first - ar[num].first);
num--;
res.push_back(ar[las].second);
las--;
}
for(int i = num ; i >= 0 ; i--)
res.push_back(ar[i].second);
reverse(res.begin() , res.end());
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... |