| 16 | */ |
| 17 | |
| 18 | signed main() { |
| 19 | int n, x; |
| 20 | cin >> n >> x; |
| 21 | int a[n]; |
| 22 | for(int i = 0; i < n; i++) |
| 23 | cin >> a[i]; |
| 24 | map<int, int> m; // map will keep track for the sum from the first index to |
| 25 | m[0] = 1; |
| 26 | int ans = 0; |
| 27 | int curr = 0; |
| 28 | for(int i = 0; i < n; i++) { |
| 29 | curr += a[i]; |
| 30 | int req = curr - x; |
| 31 | if(m.count(req)) { |
| 32 | ans += m[req]; |
| 33 | } |
| 34 | m[curr]++; |
| 35 | } |
| 36 | cout << ans <<"\n"; |
| 37 | return 0; |
| 38 | } |
nothing calls this directly
no outgoing calls
no test coverage detected