question -https://codeforces.com/contest/1417/problem/B
my sol-https://ide.codingblocks.com/s/346620
i am failing in second test case, please check my code and tell me why i am failing and what are the flaws in my code and what would me the better approach to solve this problem