Choosing Cook Off ProblemsProblem code: COOKOFF |
All submissions for this problem are available.
Dave is having trouble choosing problems for the upcoming cook-off. The admins will be mad at him if he doesn't select problems with a gradually increasing level of difficulty. To make his task easier, Dave has assigned a difficulty rating to each problem he has written. A difficulty gap is defined as the absolute difference in difficulty rating between 2 problems, where there is no other problem with a difficulty rating between them. For example, if problems are chosen with difficulty ratings of 4, 7, 13, and 19, then the difficulty gaps are 3, 6, and 6. Dave has already chosen 2 problems for the cook-off, and wants to choose the remaining problems in a way that minimizes the largest difficulty gap.
Input
Input begins with an integer T, the number of test cases. Each test case begins with 4 integers N M C1 C2 on a line. N is the number of problems to choose from (not including the two already chosen problems). M is the number of problems that must be chosen (in addition to the two that have already been chosen). C1 and C2 are the difficulty ratings of the 2 problems that have already been chosen. Following this is a line with exactly N integers, giving the difficulty ratings of the remaining problems. Again, the 2 already chosen problems are not included in the values of N and M. A blank line separates each test case, including a blank line after the number of test cases.
Output
For each test case, output on a single line the minimum possible value of the largest difficulty gap.
Sample Input:
3 3 1 0 100 16 45 61 5 0 50 80 20 40 60 80 100 6 3 0 100 21 64 34 55 64 89
Sample Output:
55 30 34
Contsraints
T?2500?M?N?1000
All difficulty ratings are between 0 and 1000000, inclusive.
| Author: | pieguy |
| Date Added: | 9-11-2010 |
| Time Limit: | 2 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, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions

I am getting TLE. Can anybody
I am getting TLE. Can anybody please view my solution - http://www.codechef.com/viewsolution/404932
and tell where am I going incorrect wrt optimization.