# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
641644 | device | 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;
int main() {
std::vector<int> find_subset(int l, int u, vector<int> w) {
vector<pair<int,int>> v(n);
for (int i = 0; i < n; i++) v[i] = w[i], v[i].second = i;
sort(v.begin(), v.end());
int cur = 0, ptr = 0;
for (int i = 0; i < n; i++) {
cur += v[i].first;
while (cur > u && ptr <= i) {
cur -= v[ptr].first;
ptr++;
}
if (cur >= l && cur <= u) {
vector<int> ret;
for (int j = ptr; j <= i; j++) ret.push_back(v[j].second);
return ret;
}
}
return vector<int>(0);
}