Untitled

mail@pastecode.io avatar
unknown
c_cpp
a year ago
505 B
4
Indexable
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int N, K;
    cin >> N;

    vector<int> prices(N);
    for(int i = 0; i < N; i++) {
        cin >> prices[i];
    }

    cin >> K;

    int count = 0;
    for(int i = 0; i < N - 1; i++) {
        for(int j = i + 1; j < N; j++) {
            if(abs(prices[i] - prices[j]) == K) {
                count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}