WA and NZEC on correct code

I’ve checked my code several times but I can’t seem to find out why it is considering wa and niece on my code. I can’t find any situation where array index is negative or where output is wrong. I’m using python 3.6.

Code: https://www.codechef.com/viewsolution/28524166

It crashes on this random testcase:

7 71
40 17 30 56 30 3 57
4 2 3 3 3 3 1 1 2 3 1 4 3 1 2 1 2 1 2 3 2 4 1 2 2 3 3 4 2 4 4 2 2 2 4 4 1 4 4 2 2 1 1 4 1 2 1 2 2 2 1 4 1 1 1 2 4 3 1 1 3 4 2 4 2 2 3 2 1 3 3 3 3 3 2 3 4 2 4 2 3 4 1 4 1 1 1 4 4 2 4 2 1 2 1 2 3 3 3 3 1 1 1 3 3 3 1 3 4 1 4 3 4 4 2 4 4 2 3 3 3 3 4 4 4 4 1 2 3 4 4 3 4 1 2 3 3 2 1 2 2 4 4 2 3 1 1 2 3 4 1 1 2 4 4 1 4 1 2 2 4 1 4 3 1 1 1 3 3 1 1 4 4 4 1 2 1 2 4 3 1 4 3 2 3 3 2 2 3 3 3 2 3 3 4 4 3 1 2 1 1 2 1 1 2 1 2 2 2 1 4 2 4 2 3 3 4 4 4 2 2 3 3 1 1 3 4 3 3 1 4 3 3 4 3 4 4 1 1 2 1 4 3 1 1 2 3 1 1 2 2 3 4 1 3 4 3 2 3 1 2 2 3 4 1 2 3 4 2 3 1 2 2 4 2 3 1 4 3 1 2 4 3 1 4 1 1 2 2 3 2 4 4 1 3 4 2 2 3 3 4 4 4 2 3 2 4 3 1 2 3 2 1 2 3 1 2 3 2 4 1 4 3 4 4 1 3 1 2 1 3 2 4 2 3 2 3 2 4 4 3 3 1 3 4 3 3 1 1 1 4 1 4 2 4 3 3 2 3 4 3 1 1 2 2 3 4 1 4 3 4 2 1 4 1 4 3 3 1 3 3 4 4 2 2 3 4 4 1 2 3 3 2 4 4 4 2 3 4 2 2 3 3 2 2 3 2 4 2 2 3 4 1 2 2 2 4 1 1 4 3 4 2 4 3 2 3 4 4 2 1 1 4 4 3 2 2 4 1 3 1 3 3 1 4 4 3 4 4 3 3 2 2 1 2 4 2 4 4 1 2 4 2 1 3 4 2 1 3 3 3 3 1 1 3 1 4 1 4 4 4 2 1 1 2 2 1 3 2 4 4 3 3 1 3 2 4 1 2 2 3 4 4 3 1 2 3 4 3 2 3 2 4 4 2 1 1 2 4 2 1 3 4 4 3 3 1 2 3 2 3 1 1 2 3 1 3 2 1 1 3 3 2 2 2 4 3 3 1 2 4 2 4 4 1 2 2 1 3 4 2 1 4 2 2 2 3 4 3 3 1 2 1 0

Edit:

Heck, it even crashes on the sample input:

3 5
2 5 2
3 2 4 2 2 2 1 4 1 1 1 1 0
2 Likes

I fixed the NZEC https://www.codechef.com/viewsolution/28524666

But it still gives WA. I fixed it by taking the second example. I can’t use the first one due to some reason. When I copy it to the terminal it doesn’t paste the whole.

This solution fails on the following testcase:

16 72
14 53 55 16 48 62 42 18 72 45 67 57 42 66 36 20
1 1 4 2 4 2 2 4 2 4 3 2 4 0
2 Likes

https://www.codechef.com/submit/complete/28525085

Thanks a billion for the help.

1 Like