ll@n,@b,a[b+1]{}; rep(n){ ll@p,@c,@s,@d; rep(j,c){ rrep(i,b-p+1){ a[i+p]>?=a[i]+s; } s-=d*2; if(s<0)break; } } wt(a[b]);