Building Blocks ¢̣

Accepts: 8
Submissions: 253
Time Limit: 4000/2000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
Problem Description
LeLe is playing with blocks again.He wants to rebuild the blocks which he built yesterday. LeLe wants to build piles which contains consecutive $W$ piles with the same height and the height is not shorter than $H$. LeLe already put all of his blocks in these piles, which means he can not add any blocks into them.Besides, he can move a block from one pile to another or a new one£¬but not the position betweens two piles already exists.For instance,after one move,"3 2 3" can become "2 2 4" or "3 2 2 1",but not "3 1 1 3". You are request to calculate the minimum blocks should LeLe move and the height.
Input
There are multiple test cases, about $100$ cases. The first line of input contains three integers $n,W,H(1 \leq n,W,H \leq 50000)$.$n$ indicate $n$ piles blocks. For the next line ,there are $n$ integers $A_1,A_2,A_3,¡­¡­,A_n$ indicate the height of each piles.$(1 \leq A_i \leq 50000)$. The height of a block is 1.
Output
For each case, output two integers,the first one is $h$ (indicate the height of W piles),the second one is the minimum number of blocks should LeLe move. If there are multiple solutions output the maximal $h$. If there is no solution, output "-1" (without quotes).
Sample Input
3 3 2
4 2 4
4 3 4
6 6 3 10
4 4 4
1 2 3 4
Sample Output
3 2
5 2
-1
Hint
In first case, LeLe moves one block from first pile to second pile and move one block from third pile to the right (out of three piles).The number of piles become 3 3 3 1, The minimum step is two. In second case, LeLe moves a block from first pile and second pile to third pile.