Dynamic programming
In this case the value of the goal function is
r
w
k+ 1 +s
kw w
k+ 1=
r
w
k+ 1 +s
kw(k+ (^1) ) w
k+ 1
=
=
r
w
k+ 1 +s
k^2 w
k+ 1 =(^1 +k)r
w
k+ 1 =p
1 +kp
w.But we should also checkc=0 andc=w.Ifc=0 then
p
kw<p
1 +kp
w,ifc=w then p
w<p
1 +kp
w
so
VT 1 (w)=p
1 +kp
w