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?
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 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]
.