Maximum Cyclic Segment Sum by 51b

import std.stdio;void main(){int n,i,j,s,I,J,M;for(int[99]a;~scanf("%d",&a[n++]);)if(getchar%4){for(i=n;i--;)for(j=i,s=0;j<i+n;s>M?I=i,J=j,M=s:0)s+=a[j++%n];for(;I<J;)writef(a[I%n],J-++I?" ":\n);M=n=0;}}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page