fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. #include <map>
  5.  
  6. using namespace std;
  7.  
  8. #define FOR(i,a,b) for(int i=a; i<=b; i++)
  9. #define DOWN(i,a,b) for(int i=a; i>=b; i--)
  10.  
  11. typedef long long LL;
  12. typedef map<LL,int>::iterator IT;
  13.  
  14.  
  15. int main()
  16. {
  17. int n;
  18. LL B,T=0;
  19. vector<LL> a;
  20. map<LL,int> count;
  21. map<LL,bool> checked;
  22.  
  23. cin>>n>>B;
  24.  
  25. a.resize(n+1);
  26. FOR(i,1,n)
  27. {
  28. cin>>a[i];
  29. T += count[B - a[i]];
  30. count[a[i]]++;
  31. }
  32.  
  33. cout<<T<<endl;
  34.  
  35. return 0;
  36. }
Runtime error #stdin #stdout #stderr 0s 4484KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc