标签:des style color io os java ar strong for
6 -2 11 -4 13 -5 -2 10 -10 1 2 3 4 -5 -23 3 7 -21 6 5 -8 3 2 5 0 1 10 3 -1 -5 -2 3 -1 0 -2 0
20 11 13 10 1 4 10 3 5 10 10 10 0 -1 -2 0 0 0HintHint#include <stdio.h> #include <algorithm> #include <iostream> #define MAXN 10000 + 10 using namespace std; int num[MAXN]; int main() { int n; int MAX,left,right; int flag; while(~scanf("%d",&n)) { memset(num,0,sizeof(num)); if(n == 0) { break; } int i; for(i=0; i<n; i++) { scanf("%d",&num[i]); } //flag = num[0]; left = num[0]; right = num[0]; MAX = num[0]; int count = 0; for(i=0; i<n; i++) { if(count < 0) { count = 0; flag = num[i]; } count=num[i]+count; if(count > MAX) { right = num[i]; MAX = count; left = flag; } } if(MAX >= 0) { printf("%d %d %d\n",MAX,left,right); } else { printf("0 %d %d\n",num[0],num[n-1]); } } return 0; }
标签:des style color io os java ar strong for
原文地址:http://blog.csdn.net/zcr_7/article/details/39456259