ll@N,@I,D[2I]{};rep(N){ll@s,@a;rrep(j,s,2I)D[j]>?=D[j-s]+a;}wt(D[I]);