Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int mod(int a,int b){
- if (a - b >=0 ){
- return a-b;
- }
- else{
- return b-a;
- }
- }
- int main(){
- int N,K;
- cin >> N >> K;
- int A[N];
- for (int i = 0; i < N; i++){
- cin >> A[i];
- }
- sort(A,A+N);
- reverse(A,A+N);
- int count;
- for (int i=0; i<N; i++){
- for(int j = i; i<N; i++){
- if(mod(A[i],A[j])>= K){
- count++;
- }
- }
- }
- cout << count << endl;
- }
Add Comment
Please, Sign In to add comment