GlobeX Cup '19 J3 - Codex

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Alex is creating a codex (list), S, of all the planets known in the universe and their sizes. However, since there are so many of them, he wants to remove all planets such that |S_i - S_j| \leq K, where i and j are arbitrary indexes.

Input Specification

The first line will contain two integers, N (1 \leq N \leq 10^5) and K (1 \leq K \leq 10^{15}).

The next N lines will each contain a string, P (1 \leq |P| \leq 100), the planet's name, followed by a space, followed by an integer, S (1 \leq S \leq 10^{15}), the diameter in kilometers of the planet.

Output Specification

The output will contain the space separated names of all the planets in Alex's codex, in lexicographical order.

Sample Input

4 2
Planet 100
AnotherPlanet 50
3rdPlanet 2
4thPlanet 3

Sample Output

AnotherPlanet Planet


There are no comments at the moment.