Category
Similar Problems
0781. Sum of array elements
Time limit : 1000 ms
Memory limit : 64 mb
You are given integers a1, ..., an and an integer number s. Your task is to determine how many consecutive non-empty sets of integers al, al + 1, ..., ar (l ≤ r) have the sum al + al + 1 + ... + ar = s.
Input
The first line contains two integers separated by space: n and s (1 ≤ n ≤ 105, - 1014 ≤ s ≤ 1014). The second line contains n integers separated by space: ai ( - 109 ≤ ai ≤ 109).
Output
Output the only integer — the number of consecutive non-empty sets of integers which have the sum s.
Samples
№ |
Input |
Output |
1 |
5 2 |
5 |
2 |
6 3 |
3 |
Text from: codeforces.ru