Devu and votes

plz give seudo code …or plz explain i am not able to understand how dp working,plzz