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<long long> find_subset(int l, int u, vector<int> w)
{
int n = w.size();
vector<pair<int, int> > vec;
vector<long long> pre(n+1), cevap;
for(int i = 0; i < n; i++)
{
vec.push_back({w[i], i});
}
sort(vec.begin(), vec.end());
for(int i = 0; i < n; i++)
pre[i+1] = pre[i] + vec[i].first;
for(int i = 1; i <= n; i++)
{
int low = 0, high = n - i + 1;
while(low <= high)
{
int mid = (low + high) / 2;
long long sum = pre[mid + i] - pre[mid];
if(l <= sum and sum <= u)
{
for(int j = mid; j <= mid + i; j++)
cevap.push_back(vec[j].second);
break;
}
else if(sum < l)
low = mid + 1;
else
high = mid-1;
}
if(cevap.size())
break;
}
return cevap;
}
# | 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... |