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;
#define ll long long
vector<int> find_subset(int L, int R, vector<int> v)
{
int n = v.size();
vector<pair<int,int>> w(n);
for (int i = 0; i < n; i++)
w[i] = make_pair(v[i], i);
sort(w.begin(), w.end());
deque<int> Q;
vector<int> result;
ll sum = 0;
if (w[0].first > R)
return result;
if (R - L < w[n-1].first - w[0].first)
return result;
for (int i = 0; i < n; i++)
{
if(L <= sum && sum <= R)
break;
sum += w[i].first;
Q.push_back(w[i].second);
if (sum > R)
{
sum-= v[Q.front()];
Q.pop_front();
}
}
if (L <= sum && sum <= R)
while(!Q.empty())
{
result.push_back(Q.front());
Q.pop_front();
}
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... |