I have been trying to solve (Kth problem the pdf)this problem for a couple of days. I find this problem very hard and the DP states and transitions are too confusing for me. I don't know how to go about thinking these types of problems :( Can someone please explain how to approach this problem? It will be very helpful.