1 人解决，3 人已尝试。
1 份提交通过，共有 7 份提交。
9.9 EMB 奖励。
单点时限: 2.0 sec
内存限制: 256 MB
For her spectacular milk output for the previous month, Farmer John has awarded Bessie a prize – with a twist. He has given her a triangular grid with () rows (whose lengths vary from through , of course). Row of the the grid has i values labeled () where is in the range .
Bessie chooses a sub-triangle whose side length is at least () within the triangular grid. The sub-triangle is another triangular grid which might be oriented the same as the original triangle or might be “upside down” with its shorter rows on the bottom instead of the top.
After she chooses her sub-triangle, Farmer John will take the average of all the numbers in the sub-triangle, discarding the digits to the right of the decimal point, and give her that many gold coins (or take that many gold coins from her if the number is negative). Naturally, Bessie would like to maximize her prize (or minimize her loss). Help her solve this problem.
By way of example, Bessie is given this triangular grid with rows and must choose a sub-triangle with a side length of at least . A graphical representation of the triangle is shown below:
/ \ / 5 \ /-8 4\ /2 -3 6\ ---------
She could choose any of five valid sub-triangles (one of which is
the entire original triangle):
/ \ / \ / \ / \ /5 \ / 5 \ / \5\ / 5 \ / 5/\ /----\ /-8 4\ /-8 \4\ /-8 4\ /-8/ 4\ /\-8 4/\ /2 -3 6\ / 2 -3\6\ /-------\ / 2/-3 6\ / 2\-3/6 \ --------- --------- -2 -3 6 --------- ---------- entire lower top lower upside triangle left right down
The one that is lined below is the one with the highest average:
/ \ / 5/\ /-8/ 4\ / 2/-3 6\ ---------
The average of this sub-triangle is , which is about ; without the fraction, the answer is .
Help Bessie calculate the maximum amount of coins which she could receive.
Line 1: Two space-separated integers: and
Lines 2..N+1: Line will contain space-separated integers:
3 2 5 -8 4 2 -3 6
2
1 人解决，3 人已尝试。
1 份提交通过，共有 7 份提交。
9.9 EMB 奖励。