Travel Brochure
题号:NC19044
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

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 wi and . 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 = wv and b the sum of w(s) for all passing villages (including the last stop and excluding the first one).
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 i0 as the starting village of the travel and at least two more villages i1,i2,··· ,ik. Guests would start their travel from the i0-th village and visit the planned k villages in sequence by loop-line bus. Finally they will go back to the i0-th village from the ik-th one and finish their travel. If we let ik+1 = i0, the whole travel would be evaluated by the score  . You need to know the maximum possible score.

输入描述:

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 w0 to wN−1 where each wi satisfies |wi|≤ 100. We guarantee that the sum of wi would be zero. 

输出描述:

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

输入

复制
1
10
1 4 1 2 -3 -5 2 -2 2 -2

输出

复制
28.66667

说明

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.