fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int a[]={5,6,4,3,6};
  7. int n=sizeof(a)/sizeof(a[0]);
  8. int k=7;
  9. int count=0;
  10. int x=0;
  11. unordered_map<int,int>b;
  12. for(int i=0;i<n;i++){
  13. x=k+a[i];
  14. if(b.find(b[x])!=b.end()){
  15. count+=b[x];
  16.  
  17. }
  18. b[a[i]]++;
  19. }
  20. cout<<count;
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty