we can do SOS DP and then apply sqrt decomposition. (https://discuss.codechef.com/convert_to_question/121319/?node_type=comment) but my doubt is isn't it exceeding the time limit? (q^(1/2)* (17 * 2^(17))) ~ 2^30?
I have read sos dp through cf blog O(n*2^n).
I know i am missing something please help!
UPD : got accepted https://www.codechef.com/viewsolution/17055899 : i just change the implementation from dp[i][j] to h[j] with same complexity! Now, more curious to know what's actually happening?





