Categories
Development

Given n integer a1, a2, …, an and k. How many ways to choose k consecutive elements that those elements can construct a triangle? [closed]

Consecutive elements can construct a triangle if they can be divided into 3 sets as 3 edges (sum of elements in a set is the weight of 1 edge). (n <= 10^5, 0 <= a[i] <= 10^9, each element is distinct). For example: n = 6, k = 3 a = [1, 3, 4, 2, […]