don’t know the reason of wa with my code http://www.codechef.com/viewsolution/1695196 althogh i got my code accepted with different logic but i can’t see any wrong in my above code…
The test where you program gets WA is:
16 8 2
2 16 10 16 2 14 2 15 14 13 7 3 3 7 14 1
I’ve just extracted it from the system even not looking at your code