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>
#define ll long long
#define f first
#define s second
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w){
vector<pair<ll,int>> sorted; int n = (int)(w.size());
for(int i = 0;i<n;++i) sorted.push_back({w[i],i});
sort(sorted.begin(),sorted.end());
ll sum = w[0];
int j = 0, st = -1, ed = -1; vector<int> ans;
for(int i = 0;i<n;++i){
while(j+1 < n && sum+sorted[j+1].f < l){
sum += sorted[j+1].f;
++j;
}
if(j+1 < n && sum < l){
sum += sorted[j+1].f;
++j;
}
if(l <= sum && sum <= u){
st = i; ed = j;
break;
}
sum -= sorted[i].f;
}
if(st != -1){
vector<int> ans;
for(int i = st;i <= ed;++i){
ans.push_back(sorted[i].s);
}
return ans;
}
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... |