ASP - Editorial

This is funny. I had never seen a problem with so many incorrect solutions being accepted…

https://www.codechef.com/viewsolution/8614838.

Getting WA,
Unable to identify the error. Can someone help?

@ash24jal

The idea with your algo is ok, but you have a problem with your iteration.
When you break your iteration on “i”, you don’t read the remaining values. So next time you iterate on “t” you read incorrect values.

Try for instance with the following input.

2

5

10 100 11 12 13

5

1 2 3 5 4

@beroul

thank you so much for identifying that silly mistake…

@beroul You provided cases which includes test cases as this-

1

5

1 0 4 2 5

But as mentioned in constraints 1 <= a[i] <= 10^9
. 0 cannot be a valid input for a[i].

Try this one
https://code.hackerearth.com/4042b6r?key=1f1cb8bcc910e53476316147dba318ea

https://www.codechef.com/viewsolution/13425638 where my code failing …

//