Iamtui1010

capdoi.cpp

Jan 12th, 2022
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<vector>
  4. #include<unordered_map>
  5.  
  6. #define long long long
  7. #define nln '\n'
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     cin.tie(0)->sync_with_stdio(0);
  14.     cout.tie(0)->sync_with_stdio(0);
  15.     //freopen("capdoi.inp", "r", stdin);
  16.     long n, x;
  17.     cin >> n >> x;
  18.     unordered_map<long, long> sum;
  19.     long ans = 0;
  20.     while (n--){
  21.         long y;
  22.         cin >> y;
  23.         ans += sum[x-y];
  24.         ++sum[y];}
  25.     cout << ans << nln;
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment