We can get the same equation with dynamic programing. By the Bellman equation
Vt(kt) = max ct 2 [ 0 ,kt]