|
||||||||||
Max Partial Value ITime Limit: 1000/5000 MS (Java/Others) Memory Limit: 32768/65535 K (Java/Others)Total Submission(s): 1130 Accepted Submission(s): 461 Problem Description HenryFour has a number of stones which have different values from -4444 to 4444. He puts N stones in a line and wants to find the max partial value of these N stones. Assume the values of the N stones in line are: v1, v2, v3, v4, ..., vN. The partial vaule of stones from Lth stone to Rth stone (1 ¡Ü L ¡Ü R ¡Ü N) is the sum of all the stones between them. i.e. PartialV(L, R) = v[L] + v[L+1] + .... + v[R] (1 ¡Ü L ¡Ü R ¡Ü N) Since the number of stones (N) is very very large, it is quite difficult for HenryFour to find the max partial value. So could you develop a programme to find out the answer for him? Input There are several test cases in the input data. The first line contains a positive integer T (1 ¡Ü T ¡Ü 14), specifying the number ot test cases. Then there are T lines. Each of these T lines contains a positive number N followed by N integers which indicate the values of the N stones in line. 1 ¡Ü N ¡Ü 1,000,000 -4444 ¡Ü v[i] ¡Ü 4444 Output Your program is to write to standard output. For each test case, print one line with three numbers seperated by one blank: P L R. P is the max partial value of the N stones in line. L and R indicate the position of the partial stones. If there are several Ls and Rs that have the same value PartialV(Li, Ri) = P, please output the minimum pair. For pair (Li, Ri) and (Lj, Rj), we define (Li, Ri) < (Lj, Rj) if and only if: Li < Lj or (Li == Lj and Ri < Rj) Sample Input
Sample Output
Hint Huge input and output,scanf and printf are recommended. Author HenryFour@TJU Source | ||||||||||
|