February Cook Off: PSHOT Question

I want to know on which test case my logic is not working.

My logic: i am calculating min goals and max goals team “A” can score after every shot and same for team “B”. Simultaneously i am checking if max goals of “B” is less than min of “A” then i stop iterating and print the no of shots and same check i am doing for “A’s” max and “B’s” min.

Thanks in advance for helping me out through this.
my code link : https://www.codechef.com/viewsolution/29872307

please help me out ASAP

for the case :

Answer should be 7 but your code is giving 8

Thank you for your help :slight_smile: