My code got partially accepted despite there were some bugs.
partailly accepted buggy code : https://www.codechef.com/viewsolution/21051381
fully accepted code : https://www.codechef.com/viewsolution/21110233
WA cases :
5
5 1 -1 3 1
Output should be impossible, but my partially accepted code outputs 3.
16
1 -1 -1 -1 -1 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 1
Output should be 3, but my partially accepted code outputs 6.
Both of the cases give right answers in the AC code.