An array is given, and an index present in it.
A window must be chosen such that it includes the index, has this component maximized — sum(a[i]...a[j])*(j-i+1), but the component must be less than the threshold (sum(a[i]...a[j])*(j-i+1) < threshold).
How we can solve this question optimally?