My approach for this is same as many have done and maybe I’m missing something.
If anyone can provide a test case where this code fails, it would be a big help. I have also commented the code so its easier to understand. https://www.codechef.com/viewsolution/46831647
Yup I have also tried many cases . Even those which people commented on others’ posts regarding this problem. Everything seems correct so far . @cubefreak777 or @ssjgz Please help if possible.
I understand… My bad for not noticing that error . I may have missed it while trying to correct the code. But, even after correcting it, it shows WA. I understand there was the iterator error. https://www.codechef.com/viewsolution/46832400