Ciel and EggsProblem code: STREGGS |
All submissions for this problem are available.
Chef Ciel has N strange eggs. The i-th egg is broken by tapping exactly Ai times. Ciel needs to break K eggs as soon as possible for cooking a rice omelet. However she has been put in an uncomfortable situation. Someone shuffled the eggs! Ciel knows the values Ai, however she doesn't know which egg is which. She'd like to minimize the worst-case number of taps. What is the minimal number?
Input
The first line contains an integer T, the number of test cases. Then T test cases follow. The first line for each test case has 2 integers N and K. Then next line has N integers A1, A2, ..., AN.
Output
For each test case, print the minimal number of taps for the worst-case.
Constraints
1 <= T <= 10
1 <= K <= N <= 500
1 <= Ai <= 1000000 (106)
Sample Input
3 2 1 5 8 2 1 5 58 3 2 1 2 3
Sample Output
8 10 5
Output details
In the first case, if a egg isn't broken after 5 taps, she should continue to tap the same egg.
In the second case, if a egg isn't broken after 5 taps, she should tap another egg 5 times.
| Author: | laycurse |
| Date Added: | 23-08-2011 |
| Time Limit: | 8 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, TCL, TEXT, WSPC |
Comments

Fetching successful submissions

can anyone provide more test
Can anyone explain the 3rd
In third case, you just tap
I dont think so it's that way
I had not think about that
@flareneos u're right.
Array A[] is always in the
is the Ai array always in
@nnpai53 and k1ps: I don't
Can Ciel remember about
@mkagenius Yes
can anyone provide some more
@assasin143: your test case
@assasin143: please do not
Hello Admin, Is there a
@admin: If I get wrong answer
Hi i am getting the correct