LINK TO Question : CAPIMOVE Problem - CodeChef
Link to solution : CodeChef: Practical coding for everyone
Getting TLE in 2nd and 3rd subtask while my approach is same as mentioned in editorial
LINK TO Question : CAPIMOVE Problem - CodeChef
Link to solution : CodeChef: Practical coding for everyone
Getting TLE in 2nd and 3rd subtask while my approach is same as mentioned in editorial
Your code is correct and gives the correct output.
However, before removing the P[i] from the set, you are doing a binary search over the set to check whether it exists in the set or not. Its not required as the function set.erase() takes care of that.
I removed the lines where you do the binary search, and your code got accepted.
Also, since this problem has a lot of input, its better to use fast input and output (I/O).
Here is your Accepted (AC) code.
THANKS !!! It worked .
But why using binary search i am geting a TLE???