# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
783911 | Alfraganus | Detecting Molecules (IOI16_molecules) | C++14 | 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 "grader.cpp"
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size(), j = 0, i = 0, s = 0;
vector<pair<int, int>> a(n);
for(int i = 0; i < n; i ++)a[i] = {w[i], i};
while(i < n){
s += a[i].first;
i ++;
while(s > u)s -= a[j ++].first;
if(l <= s and s <= u){
vector<int> ans;
for(int x = j; x < i; x ++){
ans.push_back(a[x].second);
}
return ans;
}
}
return {};
}