ADAGAME - SPOJ Solution

Hello guys…
I was trying to do this problem from SPOJ - SPOJ.com - Problem ADAGAME

This is my solution - PqM7Hk - Online IDE & Debugging Tool - Ideone.com

Could anyone tell what edge case am I missing ( I think it passes till 8th test case). Thank you so much :slight_smile: