SOLVE

LATER

The Close-i-ness

Problem

Editorial

Analytics

Abhisek likes to play with numbers. One day, he was solving math puzzles and he came across an interesting problem.

A sorted list of N numbers are given and a number Num. We have to find the five numbers that are **closest (numerically) to Num.** A number x in the array is closest to Num if **|Num-x|** is the smallest among all such x possible.

Note: If the Num is present in given list, then it should be in the output.

Constraints:

5 < N <20

1 <Num< 10000

Input:

First input line consists of 2 integers N followed by Num

Second input line consists of N integers m1 m2 m3 .. mN denoting the numbers given in the list.

where mi's are N numbers in sorted order.

Output:

p1 p2 p3 p4 p5

where pi's are closest numbers in increasing order of absolute difference from Num. If there are two numbers with same difference, print the larger one first.

Time Limit:
1.0 sec(s)
for each input file.

Memory Limit:
256 MB

Source Limit:
1024 KB

Marking Scheme:
Marks are awarded when all the testcases pass.

Allowed Languages:
C,
C++,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala 2.11.8,
Swift,
Visual Basic

Initializing Code Editor...

{"fac9ffb": "/pagelets/show-submission/algorithm/the-close-i-ness/", "faca03b": "/pagelets/problem-author-tester/algorithm/the-close-i-ness/", "faca052": "/pagelets/problems-hint/algorithm/the-close-i-ness/", "faca023": "/pagelets/suggested-problems/algorithm/the-close-i-ness/", "faca068": "/pagelets/recommended-problems/algorithm/the-close-i-ness/"}

{}

realtime.hackerearth.com

80

d4b0bfece851eefd4986a60b6b67549669d29d26

58a29e5cae2309f04b28

/realtime/pusher/auth/