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;
std::vector<int> find_subset(int L, int U, std::vector<int> w)
{
vector<pair<int, int>> arr;
int s = w.size();
for(int i=0;i<s;i++)
arr.push_back({w[i], i});
sort(arr.begin(), arr.end());
int p1 = 0, p2 = 0, pos = -1;
long long sum = arr[0].first;
while(p1 < s)
{
if(sum >= L && sum <= U)
{
pos = 1;
break;
}
else if(sum < L)
{
p2++;
if(p2 == s)
break;
sum += arr[p2].first;
}
else if(sum > U)
{
sum -= arr[p1].first;
p1++;
}
}
vector<int> ans;
if(pos == -1)
return ans;
for(int i=p1;i<=p2;i++)
ans.push_back(arr[i].second);
return ans;
}
# | 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... |