Advertisement
rotti321

countint

Jan 9th, 2022
46
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data Copied
Advertisement