Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int mxn = 2e5;
- //#define Kin
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- #ifdef Kin
- (void)!freopen("input.txt", "r", stdin);
- (void)!freopen("output.txt", "w", stdout);
- #endif
- long long n, x;
- cin >> n >> x;
- long long sum = 0, count = 0;
- map<long long, long long> mp;
- mp[0]++;
- while (n--)
- {
- long long a;
- cin >> a;
- sum += a;
- count += mp[sum - x];
- mp[sum]++;
- }
- if (count)
- cout << count << '\n';
- else
- cout << -1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement