I was trying the 6th question Building Blocks from the much maligned IIT Bombay contest which got cancelled yesterday. Problem link: https://www.codechef.com/problems/ICC91TF

I’ve been trying to solve this problem for some time now but always end up with a WA.

I have even matched my output for all inputs with an AC code and found no differences.

My submission: https://www.codechef.com/viewsolution/15623378

AC code with which i matched my output : https://www.codechef.com/viewsolution/15618920

I can’t seem to understand whats wrong.

Any help would be appreciated.

Thanks!