概述
说明:poj 2593与poj 2479基本一样,所以下文以2593为例展开
题目
Max Sequence
Time Limit: 3000MS | Memory Limit: 65536K | |
Total Submissions: 9370 | Accepted: 3825 |
Description
Give you N integers a1, a2 ... aN (|ai| <=1000, 1 <= i <= N).
You should output S.

You should output S.
Input
The input will consist of several test cases. For each test case, one integer N (2 <= N <= 100000) is given in the first line. Second line contains N integers. The input is terminated by a single line with N = 0.
Output
For each test of the input, print a line containing S.
Sample Input
5 -5 9 -5 11 20 0
Sample Output
40
Source
POJ Monthly--2005.08.28,Li Haoyuan
解题思路
此题的解题方法属于动态规划的思想。求某个数组序列中两个不重叠的子列,并且这两个子列的和是所有满足条件的子列和中最大的一个。
为了满足不重叠,于是分别从左到右和从右到左扫描数组序列,分别用两个数组left[i]/right[j]数组存储“array[0~i]数组序列中的和最大子序列的和的值”和“array[j~n-1]数组序列中的和最大子序列的值”。于是,两个满足条件的子序列的和,可以通过求最大的 "left[i-1]+right[i]"得到。
另外求“array[0~i]数组序列中的和最大子序列的和的值”的方法,也就是求“某个数组序列和最大子序列”的问题,充分利用动态规划的思想,即可求的。
程序代码
最后
以上就是高兴保温杯为你收集整理的poj 2593 & poj 2479解题报告的全部内容,希望文章能够帮你解决poj 2593 & poj 2479解题报告所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复