SHOW:
|
|
- or go back to the newest paste.
1 | #include <bits/stdc++.h> | |
2 | using namespace std; | |
3 | const int mxn = 2e5; | |
4 | - | //#define Kin |
4 | + | //#define Kin |
5 | ||
6 | int main() | |
7 | { | |
8 | - | ios_base::sync_with_stdio(0); |
8 | + | ios_base::sync_with_stdio(0); |
9 | - | cin.tie(0); |
9 | + | cin.tie(0); |
10 | ||
11 | #ifdef Kin | |
12 | - | (void)!freopen("input.txt", "r", stdin); |
12 | + | (void)!freopen("input.txt", "r", stdin); |
13 | - | (void)!freopen("output.txt", "w", stdout); |
13 | + | (void)!freopen("output.txt", "w", stdout); |
14 | #endif | |
15 | ||
16 | - | long long n, k; |
16 | + | long long n, x; |
17 | - | cin >> n >> x; |
17 | + | cin >> n >> x; |
18 | - | long long sum = 0, count = 0; |
18 | + | long long sum = 0, count = 0; |
19 | - | map<long long, long long> mp; |
19 | + | map<long long, long long> mp; |
20 | - | mp[0]++; |
20 | + | mp[0]++; |
21 | - | while (n--) |
21 | + | while (n--) |
22 | - | { |
22 | + | { |
23 | - | long long a; |
23 | + | long long a; |
24 | - | cin >> a; |
24 | + | cin >> a; |
25 | - | sum += a; |
25 | + | sum += a; |
26 | - | count += mp[sum - x]; |
26 | + | count += mp[sum - x]; |
27 | - | mp[sum]++; |
27 | + | mp[sum]++; |
28 | - | } |
28 | + | } |
29 | - | cout << count << '\n'; |
29 | + | if (count) |
30 | - | return 0; |
30 | + | cout << count << '\n'; |
31 | else | |
32 | cout << -1; | |
33 | ||
34 | return 0; | |
35 | } |