F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Travel Brochure

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 205    Accepted Submission(s): 50


Problem Description
Welcome to Galilei Town, a high and new technology industrial development zone surrounding the Dishui lake. N villages numbered from 0 to N - 1 are located along the lake and a loop-line bus is the only transportation in this town. The bus is a one-way line passing the villages 0, 1, 2, ... , N - 1 successively, going back to the 0-th village and continuing the above route.
We may measure the landscape of the i-th villages by an integer $w_i$ and $\sum_{i=0}^{N-1}$ $w_i$ = 0. Once a traveller takes the bus from the u-th village to the v-th village, he would evaluate the experience by two coefficients a = $w_v$ and b the sum of w(s) which $b = w_0 + w_1 + ... + w_v$. The data is guaranteed that the sum $b \ge 0$. Now, as the tour guide, you need to design a travel brochure for guests who came from far away. Your task is to choose a village $i_0$ as the starting village of the travel and at least two more villages $i_1, i_2, ... , i_k$. Guests would
start their travel from the $i_0$-th village and visit the planned k villages in sequence by loop-line bus. Finally they will go back to the $i_0$-th village from the $i_k$-th one and finish their travel. If we let $i_{k+1} = i_0$, the whole travel would be evaluated by the score $\frac{1}{2} \sum_{j=0}^{k}(a_{i_{j+1}} - a_{i_j})\frac{b_{i_{j}}b_{i_{j+1}}}{a_{i_{j}}a_{i_{j+1}}}$. The negative contribution to the score are requested to be the summation of a contiguous piece. You need to know the maximum possible score.
 

Input
The first line of input contains an integer t which is the number of test cases. Then t test cases follow. For each test case, the first line consists of an integer N (3 ≤ N ≤ 100000). The second line consists of N non-zero integers
$w_0$ to $w_{N-1}$ where each $w_i$ satisfies $|w_i|$ ≤ 100. We guarantee that the sum of $w_i$ would be zero.
 

Output
For each case, output the maximum score of the whole evaluation rounded to 5 decimal places behind the decimal point in a line.
 

Sample Input
1 10 1 4 1 2 -3 -5 2 -2 2 -2
 

Sample Output
28.66667
 

Hint

The best route starts from the 5-th village. Go passing the 6-th, 7-th, 8-th, 9-th, 0-th, 1-st, 2-nd, 3-rd villages and arrive at the 4-th village. Then go around the lake to the 3-rd village. Again go to the 2-nd village and back to the 5-th village.
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 12:53:21, Gzip enabled