0.SVMC 2017 pairs1 - count the pairs


Submit solution

Points: 1 (partial)
Time limit: 1.0s
Memory limit: 10M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, C, C++, C11, CLANG, CLANGX, Classical, COBOL, Coffee, CSC, D lang, DART, F95, FORTH, Fortrn, GAS32, GO, Haskell, Itercal, Java, kotlin, LEAN, LISP, LUA, MONOVB, Nasm, OCAML, Pascal, Perl, php, PIKE, prolog, Pypy, Python, Ruby 2, RUST, Scala, SCM, SED, SWIFT, TCL, TUR, V8JS, VB, ZIG

Given N integers [0<N<=10^5], count the total pairs of integers that have a difference of K. (Everything can be done with 32 bit integers).

Input Format

1st line contains N & K (integers).

2nd line contains N numbers of the set. All the N numbers are distinct.

Output Format

One integer - the number of pairs of numbers that have a diff K.

Sample Input :

5 2

1 5 3 4 2

Sample Output :

3

Sample Input :

10 1

363374326 364147530 61825163 1073065718 1281246024 1399469912 428047635 491595254 879792181 1069262793

Sample Output :

0


Comments


  • 2
    TICHPX  commented on Jan. 7, 2019, 3:27 p.m.

    Input ko trên một dòng