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;
///Sliding Window
///Determine a subset of numbers with sum between L and R
typedef long long ll;
struct number
{
int x;
int id;
};
bool byNumber(number a,number b)
{
return a.x<b.x;
}
vector<number> A;
vector<int> find_subset(int l, int r, vector<int> w) {
int n=w.size();
for(int i=0;i<n;i++){
number x={w[i],i};
A.push_back(x);
}
sort(A.begin(),A.end(),byNumber);
int a=0,b=-1;
ll sum=0;
while(b<n){
if(l<=sum && sum<=r) break;
if(sum<l){
b++;
if(b<n) sum+=(ll)A[b].x;
}
else{
sum-=(ll)A[a].x;
a++;
}
}
vector<int> ans;
if(l<=sum && sum<=r){
for(int i=a;i<=b;i++){
ans.push_back(A[i].id);
}
}
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... |