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

建议使用的浏览器:

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

5280:Senior's Array

题目描述
One day, Xuejiejie gets an array $A$. Among all non-empty intervals of $A$, she wants to find the most beautiful one. She defines the beauty as the sum of the interval. The beauty of the interval---$[L,R]$ is calculated by this formula : beauty(L,R) = $A[L]+A[L+1]+......+A[R]$. The most beautiful interval is the one with maximum beauty.

But as is known to all, Xuejiejie is used to pursuing perfection. She wants to get a more beautiful interval. So she asks Mini-Sun for help. Mini-Sun is a magician, but he is busy reviewing calculus. So he tells Xuejiejie that he can just help her change one value of the element of $A$ to $P$ . Xuejiejie plans to come to see him in tomorrow morning.

Unluckily, Xuejiejie oversleeps. Now up to you to help her make the decision which one should be changed(You must change one element).
输入解释
In the first line there is an integer $T$, indicates the number of test cases.

In each case, the first line contains two integers $n$ and $P$. $n$ means the number of elements of the array. $P$ means the value Mini-Sun can change to.

The next line contains the original array.

$1\leq n\leq 1000$, $-10^9\leq A[i], P\leq 10^9$。
输出解释
For each test case, output one integer which means the most beautiful interval's beauty after your change.
输入样例
2
3 5
1 -1 2
3 -2
1 -1 2
输出样例
8
2
来自杭电HDUOJ的附加信息
Recommend hujie

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

源链接: HDU-5280

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

共提交 0

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