标签:des style blog http io ar color os sp
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 19895 Accepted Submission(s): 8806
1 #include<iostream> 2 #include<stdio.h> 3 #include<math.h> 4 #include<stdlib.h> 5 using namespace std; 6 #define M 10009 7 int a[M]; 8 int main() 9 { 10 //freopen("in.txt","r",stdin); 11 int n,min,i,j; 12 while(~scanf("%d",&n)) 13 { 14 int num=0; 15 if(n==0) 16 break; 17 for(i=0,min=1000;i<n;i++) 18 { 19 scanf("%d",&a[i]); 20 if(a[i]<min) 21 min=a[i]; 22 if(a[i]<0) 23 num++; 24 } 25 if(num==n) 26 { 27 printf("0 %d %d\n",a[0],a[n-1]); 28 continue; 29 } 30 int flag1,flag2; 31 flag1=flag2=0; 32 int count,sum; 33 count=min; 34 for(i=0;i<n;i++) 35 { 36 for(j=i,sum=0;j<n;j++) 37 { 38 sum+=a[j]; 39 if(sum>count) 40 { 41 flag1=i; 42 flag2=j; 43 count=sum; 44 } 45 if(sum<min) 46 break; 47 } 48 } 49 printf("%d %d %d\n",count,a[flag1],a[flag2]); 50 } 51 return 0; 52 }
标签:des style blog http io ar color os sp
原文地址:http://www.cnblogs.com/xuesen1995/p/4115618.html