DP approach to the k-Good problem?

How to device a dp solution to THIS PROBLEM. Please write a detailed answer which also explains what are overlapping sub problems and complete formation of DP.

Editorial to this proble only explains the greedy approach. Some users have also posted dp solutions on its editorial but have not explained any details.

1 Like
//