标签:des style blog http color io os ar java
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 19179 Accepted Submission(s): 8544
1 #include<stdio.h> 2 #include<string.h> 3 4 int a[10000],sum[10000],len[10000]; 5 6 int main() 7 { 8 freopen("ACM.txt","r",stdin); 9 int n; 10 while(scanf("%d",&n)!=EOF) 11 { 12 if(n==0) break; 13 int i; 14 for(i=0;i<n;i++) scanf("%d",&a[i]); 15 sum[0]=a[0]; 16 len[0]=1; 17 int maxsum=sum[0],id=0; 18 for(i=1;i<n;i++) 19 { 20 if(sum[i-1]>0) 21 { 22 sum[i]=sum[i-1]+a[i]; 23 len[i]=len[i-1]+1; 24 } 25 else 26 { 27 sum[i]=a[i]; 28 len[i]=1; 29 } 30 if(sum[i]>maxsum) 31 { 32 maxsum=sum[i]; 33 id=i; 34 } 35 } 36 if(maxsum<0) printf("0 %d %d",a[0],a[n-1]); 37 else printf("%d %d %d",maxsum,a[id-len[id]+1],a[id]); 38 printf("\n"); 39 } 40 return 0; 41 }
标签:des style blog http color io os ar java
原文地址:http://www.cnblogs.com/M-D-LUFFI/p/3997865.html