http://acm.hdu.edu.cn/showproblem.php?pid=1244状态转移方程:dp[i][j]=max(dp[i][j-1],dp[i-1][j-a[i]]+sum[j]-sum[j-a[i]]);dp[i][j]为第i段第j个数。 1 #include 2 #incl....
分类:
其他好文 时间:
2014-07-26 01:10:36
阅读次数:
287
同上题一样,求连续子序列的最大和而且比上题还要简单一些,用不到long long了直接水过 1 //#define LOCAL 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int maxn = 10000...
分类:
其他好文 时间:
2014-07-24 14:47:45
阅读次数:
271
HDU 1003 Max Sum (动规)
HDU 1231 的简化版。。。...
分类:
其他好文 时间:
2014-07-22 09:16:34
阅读次数:
157
class Solution {public: int maxSubArray(int A[], int n) { int cur_sum = 0; int max_sum = INT_MIN; for (int i=0; i max_...
分类:
其他好文 时间:
2014-07-19 15:18:15
阅读次数:
160
Problem Description
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...
分类:
其他好文 时间:
2014-07-19 08:25:40
阅读次数:
224
/*
D - 简单dp 例题
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit
Status
Description
Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum ...
分类:
其他好文 时间:
2014-07-18 22:23:25
阅读次数:
231
题意:给出一列数(n个),m次查询区间[l,r]的最大连续区间[x,y](l
思路:动态查询区间最大连续区间;
如果是求最大连续区间和:
用线段树维护最大连续和sum_sub、最大前缀和sum_prefix、最大后缀和sum_suffix。
root.sum_sub = max{l.sum_sub, r.sum_sub, (l.sum_suffix + r.sum_prefix)...
分类:
其他好文 时间:
2014-07-16 11:42:15
阅读次数:
222
HDU1003 Max Sum(求最大字段和)...
分类:
其他好文 时间:
2014-07-13 15:33:13
阅读次数:
180
本题又是一题单调队列题解。
技巧就是需要计算好前n项和Sn = a1 + a2 + ... an
这样方便处理。
记录一条单调队列,其意义是: q(head), q(head+1), ...q(tail)
其中头q(head)代表当前最佳解的起点
这样我们只需要在求某点为结尾的S[i] - S[q(head)就得到当前最佳值。
了解了单调数列,知道其中的记录意义,那么这道题就没有难度了...
分类:
其他好文 时间:
2014-07-11 00:23:07
阅读次数:
265
Max Sum
Time Limit: 2000ms Memory limit: 32768K 有疑问?点这里^_^
题目描述
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,-...
分类:
其他好文 时间:
2014-07-08 21:30:17
阅读次数:
205