At coder dp series

Please help me in understanding the logic of the problem and give me some approach