# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
802821 | Gabi88 | 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<bits/stdc++.h>
#include "molecules.h"
using namespace std;
int[] find_subset(int l, int d, int[] v){
int n = v.size();
int pref[n+1];
pref[0] = v[0]; pref[n] = (1 << 31)+5;
int poc = 0, kraj = 1;
for(int i=1; i<n; i++) pref[i] = pref[i-1] + v[i];
while(kraj <= n){
int sum = pref[kraj-1];
if (poc > 0) sum -= pref[poc-1];
if (sum >= l and sum <= d) return [poc, kraj];
else if (sum > d) poc++;
else kraj--;
}
return [];
}