Advertisement
Josif_tepe

Untitled

Mar 9th, 2021
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n, k;
  8.     cin >> n >> k;
  9.     int a[n];
  10.     for(int i = 0; i < n; i++) {
  11.         cin >> a[i];
  12.     }
  13.     long long dobri = 0;
  14.     for(int i = 0; i < n; i++) {
  15.         for(int j = i + 1; j < n; j++) {
  16.             if(abs(a[i] - a[j]) == k) {
  17.                 dobri += 1;
  18.             }
  19.         }
  20.     }
  21.     cout << dobri << endl;
  22.     return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement