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>
#include "molecules.h"
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<pair<int, int>> vec(n);
for(int i=0;i<n;i++) vec[i] = {w[i], i};
sort(vec.begin(), vec.end());
vector<long long> qs(1, 0);
for(auto e:vec) qs.push_back(qs.back()+e.first);
for(auto it = qs.begin(); it != qs.end(); it++) {
auto i2 = lower_bound(qs.begin(), qs.end(), *it + l);
if(i2 == qs.end()) return vector<int>(0);
if(*i2 - *it <= u) {
vector<int> vec; for(++it,++i2;it!=i2;it++) vec.push_back(it-qs.begin()-1);
return vec;
}
}
return vector<int>(0);
}
/*
int main() {
auto e = find_subset(10, 20, {15, 16, 17, 18});
for(auto E:e) cout << E << ' ';
}*/
# | 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... |