# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
872506 | karimov | 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 <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<long long> find_subset(long long l, long long u, vector<long long> w) {
long long n = w.size();
long long left=1,right=1;
vector<long long> arr(n+1);
arr[0]=0;
for(long long i = 1; i <= n; i++) {
arr[i] = arr[i-1]+w[i-1];
}
vector<long long>ans;
while(right <= n) {
long long x = arr[right]-arr[left-1];
// cout << x << endl;
if(x < l)right++;
else if(x > u)left++;
if(x >= l && x <= u) {
for(long long i = left-1; i < right; i++) {
ans.pb(i);
}
break;
}
if(left > right)right++;
}
return ans;
}