How many periods hit the revenue target exactly?
A streaming service in Seoul records its daily net revenue change in thousands of dollars (it can be negative after refunds). The finance team is looking at every possible block of consecutive days and wants to know in how many of these blocks the total change is exactly equal to a target value.
Task: the first line holds n and T (1 ≤ n ≤ 300, -1000 ≤ T ≤ 1000). The second line holds n integers (each from -50 to 50). Count the non-empty blocks of consecutive days whose sum equals T. Blocks with different start or end days are different even if they have the same numbers. Print the count.
Sample test
Input
6 5 1 4 0 0 3 2
Expected output
6
Your answer is also checked against 5 hidden tests.
Need a hint?
A block sum is the difference of two running totals. Remember how many times each running total has appeared.
Log in or create a free account to run your code, submit and earn points.
Run your code to see the output here. Ctrl + Enter also runs it.
