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 <bits/stdc++.h>
using namespace std;
using ll = long long ;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = w.size();
vector<pair<int,int>> t(n);
for (int i = 0; i < n; i++) t[i] = {w[i], i};
sort(t.begin(), t.end());
ll s = 0;
if (u < t[0].first)
return vector<int>();
for (int len = 1; len <= n; len++) {
s += t[len-1].first;
if (s >= l && s <= u) {
vector<int> ans;
for (int i = 0; i < len; i++) ans.push_back(t[i].second);
return ans;
}
if (s > u) {
s -= t[len-1].first; len--;
for (int i = len; i < n; i++) {
s += t[i].first - t[i - len].first;
if (s >= l && s <= u) {
vector<int> ans;
for (int j = i - len + 1; j <= i; j++) ans.push_back(t[j].second);
return ans;
}
}
break;
}
}
return vector<int>();
}
# | 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... |