CSES Problemset/Sorting and Searching
Subarray Sums II
#1661Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude DesktopGiven an array of integers, your task is to count the number of subarrays having sum .
Input
The first input line has two integers and : the size of the array and the target sum .
The next line has integers : the contents of the array.
Output
Print one integer: the required number of subarrays.
Constraints
Sample Test Cases (1)
Example 1ID: sample-1
Input
5 7 2 -1 3 5 -2
Expected Output
2
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|1 line, 0 charsTest Bench
Input (stdin)
5 7 2 -1 3 5 -2
Expected Output
2