当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5990:Travel Brochure

题目描述
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.
输入解释
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.
输出解释
For each case, output the maximum score of the whole evaluation rounded to 5 decimal places behind the decimal point in a line.
输入样例
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.
来自杭电HDUOJ的附加信息
Recommend jiangzijing2015

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5990

最后修改于 2020-10-25T23:27:20+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 32768/32768K(Java/Others)