九度1077 最大序列和
/********************************* * 日期:2013-1-13 * 作者:SJF0115 * 题号: 九度1077 * 题目:最大序列和 * 来源:http://ac.jobdu.com/problem.php?pid=1077 * 结果:AC * 题意: * 总结:**********************************/#include <stdio.h>#include <string.h>int main(){int i,n;long long sum,max,num;//freopen("C:\\Users\\SJF\\Desktop\\acm.txt","r",stdin);while(scanf("%d",&n) != EOF){sum = 0;max=-10000;for(i = 1;i <= n;i++){scanf("%lld",&num);sum += num;if(max < sum){max = sum;}if(sum < 0){sum = 0;}}printf("%lld\n",max);}return 0;}