请问杭电ACM1024题根据那个状态转移方程怎么确定初始值,以及好像根据那个转移方程每个数都要用上……为啥

请问杭电ACM1024题根据那个状态转移方程怎么确定初始值,以及好像根据那个转移方程每个数都要用上……为啥
就是每个数都是在那两种情况中选一种被加在里面……然后得出一个二维数组某个最大值……我对动态规划一直都不是很明白,更不要说拿它来做题,
Max Sum Plus Plus
Problem Description
Given a consecutive number sequence S1,S2,S3,S4 ...Sx,...Sn (1 ≤ x ≤ n ≤ 1,000,000,-32768 ≤ Sx ≤ 32767).We define a function sum(i,j) = Si + ...+ Sj (1 ≤ i ≤ j ≤ n).
Now given an integer m (m > 0),your task is to find m pairs of i and j which make sum(i1,j1) + sum(i2,j2) + sum(i3,j3) + ...+ sum(im,jm) maximal (ix ≤ iy ≤ jx or ix ≤ jy ≤ jx is not allowed).
But I`m lazy,I don't want to write a special-judge module,so you don't have to output m pairs of i and j,just output the maximal summation of sum(ix,jx)(1 ≤ x ≤ m) instead.
Input
Each test case will begin with two integers m and n,followed by n integers S1,S2,S3 ...Sn.
Process to the end of file.
Output
Output the maximal summation described above in one line.
Sample Input
1 3 1 2 3
2 6 -1 4 -2 3 -2 3
状态转移方程:B[i][j]=max{B[i][j-1]+A[j],B[i-1][t]+A[j] (i-1
如石恐龙 1年前 已收到1个回答 举报

tekken2002 幼苗

共回答了22个问题采纳率:95.5% 举报

我打算今晚就做这道题!如果我做出来的话!就和你分享吧!问题真的比较难!
尽量做吧!尽量参考别人的代码吧!

1年前

5
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 1.063 s. - webmaster@yulucn.com