#C8556. Counting Valid Splits

    ID: 52551 Type: Default 1000ms 256MiB

Counting Valid Splits

Counting Valid Splits

You are given an array of n integers and an integer X. Your task is to determine the number of ways to split the array into two non-empty contiguous subarrays such that the sum of the elements in both subarrays is at least X.

Let the array be denoted as \(a_1, a_2, \dots, a_n\). A split between indices \(i\) and \(i+1\) (with \(1 \le i < n\)) is considered valid if both \[ \sum_{j=1}^{i}a_j \ge X \quad \text{and} \quad \sum_{j=i+1}^{n}a_j \ge X \] hold true.

Your program should read input from stdin and output the result to stdout.

inputFormat

The first line contains two integers n and X where n is the number of elements in the array and X is the threshold value. The second line contains n space-separated integers representing the array.

Example:

5 5
5 1 3 2 4

outputFormat

Output a single integer representing the number of valid splits.

Example:

3
## sample
5 5
5 1 3 2 4
3

</p>