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