Racing HorsesProblem code: HORSES |
All submissions for this problem are available.
Chef is very fond of horses. He enjoys watching them race. As expected, he has a stable full of horses. He, along with his friends, goes to his stable during the weekends to watch a few of these horses race. Chef wants his friends to enjoy the race and so he wants the race to be close. This can happen only if the horses are comparable on their skill i.e. the difference in their skills is less.
There are N horses in the stable. The skill of the horse i is represented by an integer S[i]. The Chef needs to pick 2 horses for the race such that the difference in their skills is minimum. This way, he would be able to host a very interesting race. Your task is to help him do this and report the minimum difference that is possible between 2 horses in the race.
Input:
First line of the input file contains a single integer T, the number of test cases.Every test case starts with a line containing the integer N.
The next line contains N space separated integers where the i-th integer is S[i].
Output:
For each test case, output a single line containing the minimum difference that is possible.Constraints:
1 ≤ T ≤ 10 2 ≤ N ≤ 5000 1 ≤ S[i] ≤ 1000000000
Example:
Input:1 5 4 9 1 32 13Output:
3Explanation: The minimum difference can be achieved if we pick horses with skills 1 and 4 for the race.
| Author: | vamsi_kavala |
| Tester: | laycurse |
| Editorial | http://discuss.codechef.com/problems/HORSES |
| Date Added: | 2-07-2012 |
| Time Limit: | 3 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS
Fetching successful submissions


what if two horses have same
@vineetsetia We can choose
Well... The answer I
OMG it now shows correct
why is my submission taking
My code is perfectly running
my input and output are
any tricky test cases?
using delete[ ] in my program
can anybody tell me how to
is the name of input file is
hey @admin plz reply how to
@admin: what is the memory
Is the time limit not
i am new here....i have coded
what is the memory limit for
Anyone pls reply how the
output for more than one
@admin please tell me the
@admin i solved this question
if S[i] is -ve no then what
@mi_ke: there is a
Can anyone please tell me how
Is anyone knows using which
How do you do a next line in
why am i getting wring ans on
Time limit for the above
getting runtime error , how
how to check runtime error
my prog in gcc compiler run
@Admin Please provide some
my code is running on my
@Admin : Please clarify if
@admin: plz specify the test
@admin How do I know the test
@admin my program is
@spider3091 and others with
can any one please tell me
can any1 say me whats the
can any1 tell me if there has
What does test case here does
How to give output in the
what's the input file name
ha ha ha...1st attempt (my
Compiler not accepting abs()
run time error :( my program
My code is perfectly running
its giving run time error any
@admin: can i get some more
@admin or can anyone tell me
...