hdu1231

/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

int n;
int a[10005];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	while(scanf("%d", &n) == 1){
		if(!n) break;
		for (int i = 1; i <= n; i++){
			scanf("%d", &a[i]);
		}
		int l = a[1], r = a[1], l1 = a[1];
		int maxx = a[1];
		int now = 0;
		for (int i = 1; i <= n; i++){
			if(now < 0){
				now = a[i];
				l1 = a[i];
			}else now += a[i];
			if(now > maxx){
				l = l1;
				maxx = now;
				r = a[i];
			}
		}
		if(maxx < 0){
			printf("0 %d %d\n", a[1], a[n]);
		}else{
			printf("%d %d %d\n", maxx, l, r);
		}
	}

	return 0;
}
/**/

 

全部评论

相关推荐

生命诚可贵:先不说内容怎么样 排版就已经太差劲了 第一眼看不到重点,第二眼已经没有再看的耐心了, 篇幅占的太满了 字体不要用灰色 观感不好 想重点突出的黑色加粗就可以了 多列要点 少些大段的句子 项目经历把项目用的技术要点列出来,光写个python plc什么的太宽泛了 自我评价也有点偏多
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务