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){
vector<pair<int, int>> a;
int curr = 1;
int _sum = 0, n = w.size();
for(int i : w) a.emplace_back(i, curr++), _sum += i;
sort(a.begin(), a.end());
for(int _=0; _<2; ++_){
int sum = _sum;
int j = 0;
for(int i=0; i<n; ++i){
sum += a[i].first;
while(j<=i) sum -= a[j++].first;
while(j<n and sum>u) sum -= a[j++].first;
if(l<=sum and sum<=u){
vector<int> ans;
for(int k=0; k<=i; ++k) ans.push_back(a[k].second);
for(int k=n-1; k>=j; --k) ans.push_back(a[k].second);
sort(ans.begin(), ans.end());
return ans;
}
}
reverse(a.begin(), a.end());
}
return {};
}
# | 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... |