Segments greater than K
Time limit2sMemory limit512 MB
Count the contiguous subarrays whose sum exceeds k.
- Level
Medium5 of 10
- Topics
- Two pointers, Prefix sum
- Solved
- No attempts yet
Problem
A sequence of natural numbers is given. Write a program that counts the pairs with whose segment sum is greater than .
Input
The first line contains the length of the sequence, . ()
The second line contains the natural numbers of the sequence, separated by spaces. No number is greater than .
The third line contains a natural number . ()
Output
Print the number of pairs whose segment sum is greater than on the first line.