I am trying to solve the problem RENT on SPOJ. Here is the link http://www.spoj.com/problems/RENT/.I have done it using dynamic programming and binary search. I cant figure out what is wrong with my code.Here is a link to my code : http://ideone.com/UgnBRN . Please Help.
Are you taking into account that if a rent ends at time t, then the next one has to start at least at time t + 1 ???
The statement says otherwise, I know, but you can't start a rent at the same time you end the previous one. The statement is incorrect.
Found my error. :) I was doing ar[mm] and sometimes it was returning mm=-1. So that was showing garbage values. Thanks a ton :)
Well I solved this problem allowing to begin a rent at the same time another ends. I guess there is no case like that in the test cases...
There is a test case like that in SPOJ Toolkit, but perhaps not in the official test cases. In that case, the SPOJ Toolkit solution is wrong and the problem statement is right.