my solution is working well on local compiler as well as ideone but codechef is giving WA can anyone point out error or give me test case where it is failing.

anyone please reply

5 65
30 20 1 1 1
Your code is giving 4, answer should be 3.
The first soldier attacks twice and the second, once.

ok thak you