早教吧作业答案频道 -->其他-->
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这个题目是...的网友还看了以下:
已知a向量=(3,2,1),b向量=(-1,1,3),c向量=(2,-1,m),若a,b,c三个向 2020-05-13 …
若A={X | -3≤X≤4} B={X | 2m-1≤X≤m+1 ,m≤2 } A∩B=B 求实 2020-05-16 …
如果m-(1/m)=-2,那么m^3-1/(m^3)=A.-12B.-14C.12D.14 2020-05-24 …
设集合A={-4,m^2},B={m-5,1-m},又A∩B={-4},求实数M值 2020-06-03 …
运行程序的结果,为什么,#includefunc(inta,intb){staticintm=0, 2020-07-22 …
初二数学,下列哪些是因式分解,哪些不是,为什么?①x²-3x+1=x(x-3)+1②(m+n)(a 2020-07-29 …
已知向量a=(–1,2),b=(1,m)若a与b夹角为钝角,则m的取值 2020-07-30 …
a-a^-1=m则a^2/a+1/a=? 2020-10-31 …
命题p:正实数a,b满足a2+b2=1;命题q:正实数a,b满足a3+b3+1=m(a+b+1)3, 2020-10-31 …
1.m²(a-2)+m(2-a)2.-4x²yz-12xy²z+4xyz3.45a²-20a4.-x 2020-11-07 …