本文主要是介绍https://acs.jxnu.edu.cn/problem/HDU1003,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
描述:
Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.
输入:
The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line starts with a number N(1<=N<=100000), then N integers followed(all the integers are between -1000 and 1000).
输出:
For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line contains three integers, the Max Sum in the sequence, the start position of the sub-sequence, the end position of the sub-sequence. If there are more than one result, output the first one. Output a blank line between two cases.
给定一个序列a[1],a[2],a[3]......A [n],你的工作是计算子序列的Max和。例如,给定(6,-1,5,4,-7),这个序列中的最大和是6 +(-1)+ 5 + 4 = 14。
输入:
输入的第一行包含一个整数T(1<=T<=20),这意味着测试用例的数量。然后是T行,每一行以数字N(1<=N<=100000)开始,然后是N个整数(所有的整数都在-1000到1000之间)。
输出:
对于每个测试用例,您应该输出两行。第一行是“案例#:”,#表示测试用例的数量。第二行包含三个整数,序列中的Max Sum,子序列的起始位置,子序列的结束位置。如果有多个结果,则输出第一个结果。在两种情况之间输出空行。
这篇关于https://acs.jxnu.edu.cn/problem/HDU1003的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!