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

建议使用的浏览器:

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

2479:Maximum sum

题目描述
Given a set of n integers: A={a1, a2,..., an}, we define a function d(A) as below:
__poj_jax_start__d(A)=\max_{1\leq s_1\leq t_1<s_2\leq t_2\leq n}\left\{\sum_{i=s_1}^{t_1}a_i+\sum_{j=s_2}^{t_2}a_j\right\}__poj_jax_end__
Your task is to calculate d(A).
输入解释
The input consists of T(<=30) test cases. The number of test cases (T) is given in the first line of the input.
Each test case contains two lines. The first line is an integer n(2<=n<=50000). The second line contains n integers: a1, a2, ..., an. (|ai| <= 10000).There is an empty line after each case.
输出解释
Print exactly one line for each test case. The line should contain the integer d(A).
输入样例
1

10
1 -1 2 2 3 -3 4 -4 5 -5
输出样例
13
提示
In the sample, we choose {2,2,3,-3,4} and {5}, then we can get the answer.

Huge input,scanf is recommended.

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2479

最后修改于 2020-10-29T06:33:39+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536