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 <vector>
#include <algorithm>
#include <iostream>
using ll = long long;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
sort(w.begin(), w.end());
std::vector<int> ans;
int n = w.size();
ll pre = 0, suf = 0;
for (int i = 1; i <= n; i++){
pre += w[i-1]; suf += w[n-i];
if (pre > u){ return ans; }
if (l <= pre && pre <= u){
for (int j = 0; j < i; j++){ ans.push_back(j); }
return ans;
}
if (l <= suf && suf <= u){
for (int j = n-i; j < n; j++){ ans.push_back(j); }
return ans;
}
if (pre < l && u < suf){
ll sum = pre;
for (int j = 0; j+i < n; j++){
if (l <= sum && sum <= u){
for (int k = j; k < j+i; k++){ ans.push_back(k); }
return ans;
}
sum -= w[j];
sum += w[j+i];
}
}
}
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... |