fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int n;cin>>n;
  6. int k;cin>>k;
  7. vector<int> arr(n);
  8. unordered_map<int,int> mp;
  9. int count=0;
  10. for(int j=0;j<n;j++)
  11. {
  12. cin>>arr[j];
  13. int x=k-arr[j];
  14. count+=mp[x];
  15. mp[arr[j]]++;
  16. }
  17. cout<<count;
  18.  
  19.  
  20.  
  21.  
  22. }
  23.  
  24.  
  25.  
  26.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty