maximize bridge

https://www.codechef.com/viewsolution/53725957

please tell me what’s wrong with my code as it passes the examples given in question but on submitting it gives wrong answer