Problems > Windows Reaching the Target

Windows Reaching the Target

Difficulty: 1300 3000 ms 128 MB

sliding-window

Count how many contiguous windows of exactly K elements have a sum of at least T.

Input: the first line has N, K and T; the second line has N integers.

Output: the number of windows with sum ≥ T.

Constraints:

  • 1 ≤ K ≤ N ≤ 105
  • −50 ≤ ai ≤ 50
  • |T| ≤ 5×106

Sample Tests

Input 1
5 2 4
1 3 2 4 1
Output 1
4
Input 2
2 1 0
-1 1
Output 2
1

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.