Small Change by murky-satyr

System.in.eachLine{c=(it=~/\d+/)*.toShort()
e=c.remove(0)
a=[[]]
for(q=[i=0];(b=q[i++])>=0;)b<e&&c.sum{a[u=b+it]=a[u]?:q<<u?a[b]+it:0}
println a[e]?.join(' ')?:'-'}

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

download

return to the top page