早教吧作业答案频道 -->其他-->
ACMMAXSUM这个题目是什么意思,我竟然看不懂Givenasequencea[1],a[2],a[3]......a[n],yourjobistocalculatethemaxsumofasub-sequence.Forexample,given(6,-1,5,4,-7),themaxsuminthissequenceis6+(-1)+5+4=14.Inp
题目详情
ACM MAX SUM这个题目是什么意思,我竟然看不懂
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.
Input
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).
Output
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.
Sample Input
2
5 6 -1 5 4 -7
7 0 6 -1 1 -6 7 -5
Sample Output
Case 1:
14 1 4
Case 2:
7 1 6
Author
Ignatius.L
Recommend
We have carefully selected several similar problems for you: 1176 1087 1069 2084 1058
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.
Input
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).
Output
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.
Sample Input
2
5 6 -1 5 4 -7
7 0 6 -1 1 -6 7 -5
Sample Output
Case 1:
14 1 4
Case 2:
7 1 6
Author
Ignatius.L
Recommend
We have carefully selected several similar problems for you: 1176 1087 1069 2084 1058
▼优质解答
答案和解析
给定的序列a[1],a[2],a[3]......a[n],你的工作是计算最大和的一个子序列。例如,给定( 6, -1,5,4 ,-7 ) ,在这个序列中的最大总和是6 + (-1) + 5 + 4 = 14 。
输入
输入的第一行包含一个整数T( 1 <= T < = 20 )表示的多个测试案例。那么下面的T行,每行开头的一个数N( 1 <= N < = 100000 ) ,然后跟着N个整数( -1000和1000之间的所有整数)。
输出
对于每个测试的情况下,你应该输出两行。第一行是"Case #:",#表示测试情况的数目。第二行包含三个整数,最大和序列中,子序列的开始位置,结束位置的子序列。如果有一个以上的结果,输出的第一个。两种情况之间输出一个空行。
样本输入
2
5 6 -1 5 4 -7
7 0 6 -1 1 -6 7 -5
样本输出
Case 1:
14 1 4
Case 2:
7 1 6
作者
Ignatius.L
建议
我们为您精心挑选了几个类似的问题:1176 1087 1069 2084 1058
输入
输入的第一行包含一个整数T( 1 <= T < = 20 )表示的多个测试案例。那么下面的T行,每行开头的一个数N( 1 <= N < = 100000 ) ,然后跟着N个整数( -1000和1000之间的所有整数)。
输出
对于每个测试的情况下,你应该输出两行。第一行是"Case #:",#表示测试情况的数目。第二行包含三个整数,最大和序列中,子序列的开始位置,结束位置的子序列。如果有一个以上的结果,输出的第一个。两种情况之间输出一个空行。
样本输入
2
5 6 -1 5 4 -7
7 0 6 -1 1 -6 7 -5
样本输出
Case 1:
14 1 4
Case 2:
7 1 6
作者
Ignatius.L
建议
我们为您精心挑选了几个类似的问题:1176 1087 1069 2084 1058
看了 ACMMAXSUM这个题目是...的网友还看了以下:
已知m,n是自然数,a^m-3*b^2*c-1/7a^2*b^n-3*c^4+1/12a^m+1* 2020-06-12 …
1.下列加点字注音有误的一项是()A.垂髫(tiáo)邑人(yi)夹岸(jiā)B.问津(jīn) 2020-06-28 …
1.下列加点字注音完全正确的一项是()A.元勋(x?n)邓稼先(jià)妇孺皆知(rú)B.殷红( 2020-07-23 …
1.下面加点字注音完全正确的是()。A.元勋(xūn)邓稼先(jià)妇孺皆知(rú)B.殷红(y 2020-07-23 …
组合数学递推关系看不懂...下了好几份课件,看了很久依然看不懂怎么由特征根方程求得a(n)通项公式 2020-08-01 …
请教几个大学离散数学里等价关系的问题,求大神回答1:证明自然数集上的模m同余关系是等价关系2:令N 2020-08-02 …
证明组合性质:C(n+1,m)=C(n,m)+C(n,m-1)C(n+1,m)=(n+1)!/m!( 2020-11-01 …
设M,N为两个随机事件,如果M,N为互斥事件(.M,.N表示M,N的对立事件),那么()A..M∪. 2020-12-01 …
从n个数中取k个数可以重复有多少种不同的取法如果是n^k显然重复了很多n+k-1)忘说了123312 2020-12-02 …
请你设计程序,对于给定的自然数N确定满足下述关系的最小数S.S可以表示为两对不同的自然数的n次方幂. 2020-12-23 …