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<algorithm>
#include<assert.h>
#include<numeric>
#include<iostream>
using namespace std;
using ll = long long;
vector<int> find_subset(int weight_low, int weight_hi, vector<int> w) {
int n = w.size();
vector<pair<int, int> > v(n);
for(int i = 0; i < n; ++i)
v[i] = {w[i], i};
sort(v.begin(), v.end());
ll sum = 0, l = 0, r = 0;
while(sum < weight_low or weight_hi < sum){
if(sum < weight_low){
sum += v[r].second;
r++;
}
else if(weight_hi < sum){
assert(l <= r);
sum -= v[l].second;
l++;
}
else
assert(false);
}
vector<int> ans;
if(weight_low <= sum and sum <= weight_hi){
for(int i = l; i <= r; ++i){
ans.push_back(v[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... |