# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
974785 | d4xn | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
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> sb;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = w.size()-1;
int sum = 0;
int R = -1;
while (R+1 < n && sum + w[R+1] <= u) {
sum += w[++R];
sb.push_back(R);
}
if (l <= sum) return sb;
int L = n;
while (min(R, L-1) >= 0 && sum - a[R] + a[L-1] <= u) {
sum += w[--L] - w[R--];
sb.pop_back();
}
for (int i = n-1; i >= L; i++) {
sb.push_back(i);
}
if (sum < l || r < sum) sb.clear();
return sb;
}