Maximum Cyclic Segment Sum by shinh

#!ruby -na
n=$F.size
f=$F*2
m=[]
n.times{|i|v=0
n.times{|j|m[9999+v+=f[i+j].to_i]=f[i,j+1]}}
puts m[-1]*' '

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

download

return to the top page