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;
vector<int> ans;
vector<pair<int,int>> p;
int i, j, n;
long long sum;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
n = w.size();
for (i=0; i < n; i++) {
p.push_back(make_pair(w[i], i));
}
sort(p.begin(), p.end ());
i = 0;
j = 0;
sum = (long long)p[0].first;
while (j < n) {
if ((long long)l <= sum && sum <= (long long)u) {
break;
}
else if (sum < (long long)l) {
if (j+1 == n) {
break;
}
sum += (long long)p[++j].first;
}
else {
sum -= (long long)p[i++].first;
}
}
if (l <= sum && sum <= u) {
for (int x=i; x <= j; x++) {
ans.push_back(p[x].second);
}
}
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... |