题目传送:HDU - 1003
思路:最大子序列和
dp[i]= a[i] (dp[i-1]
dp[i]= dp[i-1]+a[i] (dp[i-1]>=0)
AC代码:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#includ...
分类:
其他好文 时间:
2015-05-07 08:49:44
阅读次数:
203
Water ~ 1 #include 2 #include 3 #include 4 5 using namespace std; 6 const int INF=100000000; 7 8 int t,n,a; 9 int main()10 {11 cin>>t;12 ...
分类:
其他好文 时间:
2015-05-06 22:41:33
阅读次数:
146
Max Sum
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 168618 Accepted Submission(s): 39345
Problem DescriptionGiven a sequence a[1],a[...
分类:
其他好文 时间:
2015-05-06 15:14:52
阅读次数:
81
一开始,看到这题,以为是最大连续子序列和的问题,写出了代码,提交了,WR,找了一些测试数据,结果发现这个算法并不能将所以的序列的解求出,只是满足一部分序列。
百度了一下,知道了要用单调队列来求解。
单调队列,也就是队列中必然是单调递减的或者递增的。而这题使用的是单调递增的队列。
单调队列使用的是双向队列,队尾队头都可以删除元素,只能从队尾插入元素。
比如求解一个数列{1 ,2 ,5 ,...
分类:
其他好文 时间:
2015-05-05 14:35:54
阅读次数:
173
点击打开杭电1024
Problem Description
Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced wi...
分类:
其他好文 时间:
2015-04-30 12:38:42
阅读次数:
214
点击打开杭电1003
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 i...
分类:
其他好文 时间:
2015-04-29 11:46:20
阅读次数:
118
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, ...
分类:
其他好文 时间:
2015-04-27 21:51:49
阅读次数:
169
源码#include#includeint main(){ int n; scanf("%d", &n); for(int i = 0; i max) { max = sum[j]; c = j+'a'; break; } } printf("%c %d\n",c,ma...
分类:
其他好文 时间:
2015-04-27 01:54:56
阅读次数:
212
收获: 1、min, max, sum, 属于判定,等询问是”对象对答案贡献独立“,即不需要其他对象就了能更新答案,并保证只要所有对象更新过答案,那么该答案就是正确的。大概这就是所谓的”修改独立“。 2、处理”先把所有修改给你,再询问“问题时,这道题要用到降维思想,就是处理的顺序也是一维,并且这.....
分类:
其他好文 时间:
2015-04-25 13:40:36
阅读次数:
126
Max Sum Plus PlusTime Limit: 1 SecMemory Limit: 256 MB题目连接http://acm.hdu.edu.cn/showproblem.php?pid=1024DescriptionNow I think you have got an AC in I...
分类:
其他好文 时间:
2015-04-24 14:11:32
阅读次数:
106