fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void executeTime() {
  5. cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " secs";
  6. }
  7.  
  8. int main() {
  9.  
  10.  
  11. int n, t; cin >> n >> t;
  12.  
  13. vector<int> v(n);
  14.  
  15. for (auto &x : v) {
  16. cin >> x;
  17. }
  18.  
  19. int c = 0;
  20. unordered_map<int, int> mp;
  21. for (auto &x : v) {
  22. if (mp[t - x]) {
  23. c++;
  24. }
  25.  
  26. mp[x]++;
  27. }
  28.  
  29. cout << c << endl;
  30.  
  31. executeTime();
  32. return 0;
  33. }
Success #stdin #stdout #stderr 0s 5320KB
stdin
10 5
1 23 3 7 50
4 32 2 4 50
stdout
3
stderr
Time Taken: 0.004684 secs