Advertisement
Saleh127

CSES 1660

Apr 17th, 2021
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. ll n,m,i,j,k=0,l=0;
  11.  
  12. cin>>n>>m;
  13.  
  14. map<ll,ll>x;
  15.  
  16. ll a[n+6];
  17.  
  18. x[0]=1;
  19.  
  20. for(i=0;i<n;i++)
  21. {
  22. cin>>a[i];
  23. }
  24.  
  25. for(i=0;i<n;i++)
  26. {
  27. l+=a[i];
  28.  
  29. if(x.find(l-m)!=x.end()) k+=(x[l-m]);
  30.  
  31. x[l]++;
  32. }
  33.  
  34. cout<<k<<endl;
  35.  
  36.  
  37. return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement