标签:ase std str hdu1003 max sum case class can printf
时间复杂度O(n)
空间复杂度O(1)
1 #include <cstdio> 2 int main() { 3 int T;scanf("%d",&T); 4 for(int t=1,n,a,l,r,s,L,R,S;t<=T;t++) { 5 scanf("%d",&n),l=L=R=1; 6 for(r=1;r<=n;r++) { 7 scanf("%d",&a),r==1?s=S=a:s+=a; 8 if(s>S)S=s,L=l,R=r; 9 if(s<0)s=0,l=r+1; 10 } 11 printf("Case %d:\n%d %d %d\n",t,S,L,R); 12 if(t!=T)printf("\n"); 13 } 14 return 0; 15 }
标签:ase std str hdu1003 max sum case class can printf
原文地址:https://www.cnblogs.com/JasonCow/p/12283519.html