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> ret;
vector<pair<int,int> > v;
void get(int l, int r) {
for(int i = l; i <= r; i++)
ret.push_back(v[i].second);
}
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = w.size();
for(int i = 0; i < n; i++)
v.push_back({w[i],i});
sort(v.begin(),v.end());
if(v[0].first > u) return ret;
long long x = 0, sum = v[0].first;
while(x + 1 < n && sum + v[x + 1].first < l) { sum += v[x + 1].first; x++; }
if(x + 1 < n && sum + v[x + 1].first <= u && sum + v[x + 1].first >= l) {
get(0,x+1);
return ret;
}
if(l <= sum && sum <= u) {
get(0,x);
return ret;
}
for(int i = x + 1; i < n; i++) {
sum += v[i].first;
sum -= v[i - x - 1].first;
if(l <= sum && sum <= u) {
get(i - x, i);
return ret;
}
}
return ret;
}
# | 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... |