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;
}
/**/

 

全部评论

相关推荐

02-21 23:22
已编辑
重庆大学 Java
神哥不得了:神哥来啦~还是非常不错的。需要注意的是项目的话建议把编号换一下,把前面那个一和二删掉,然后再把123那种换成点,项目的话应该用这两个项目也问题不大,毕竟你的学历还是挺好的,如果换上两个高质量项目的话,获得面试的比例会大一点,不过这两个项目的话应该吃透,也可以找到面试,八股的话就建议先把高频top50的八股多巩固几遍,别看那些假高频题目就行
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务