I need some help with this DP problem

Revision en2, by just_try_again, 2022-05-30 10:53:59

Hey guys, I've been trying various approaches for this problem which appeared in this contest (ended). I submitted many solutions with different DP states but even my best solution gives me TLE on half of the test cases. My DP states are 'n' and the current number under consideration for the sequence, say 'i'. For each dp[n][i], I consider all cases, from the inclusion of no 'i' to the max number of times that 'i' can be included in the sequence.

I request you to share your approach(es) to this problem, please.

My submission — link

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English just_try_again 2022-05-30 10:53:59 59 Tiny change: ', please. ' -> ', please. \n\nMy submission - [link](https://ideone.com/9clm2R)'
en1 English just_try_again 2022-05-30 10:53:11 746 Initial revision (published)