Maximum Cyclic Segment Sum by ktt

for(;r=readline(T=i=0);print(S))for(l=(a=r.split(' ')).length;i<l;a[l+i]=a[i++])for(s=t=a[j=i];j<l+i;t-=-a[++j],s+=' '+a[j])t>T&&(T=t,S=s)

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

download

return to the top page