Advertisement
rotti321

countint

Jan 9th, 2022
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. long n,k,x,a=0,s=0;
  5. cin>>n>>k;
  6. map<long,long>c;
  7. c[0]=1;
  8. while(n--){
  9. cin>>x;
  10. s+=x;
  11. a+=c[s-k];
  12. c[s]++;
  13. }
  14. cout<<a;
  15. return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement