CodeForces Div-3 677

In the Dominant Piranha question, why was I getting WA?
what I did was I considered the index of the value, which is max and its adjacent is not equal to the max element. Any test case would be helpful. Thanks

Question Link: https://codeforces.com/problemset/problem/1433/C
solution link: https://ideone.com/q51Cab

It would fail in test case like this-
1
5
1 1 1 7 7
Also post the link to Q for faster responses.

1 Like

Hi, so what’s wrong in your answer is that you are considering for your answer only the next element that is at I + 1, but you also have to consider the element at i - 1 also, because it can be the case that ith element cannot eat i + 1th element but it can eat i - 1th element.
For ex:
3
2 7 7

In this case your code will output 3 as you are considering the next greater or equal element .
But its answer should be 2.

Hope you get what I am trying to say.

1 Like

Yeah including the question link makes it easier.

1 Like

yes got it…thanx and also included the question link

1 Like

yes…got it. I clearly ignored that case…thank you

I will tell you what I did :
I printed the index of the biggest element which have different element either on (index(biggest_element)+1) or on (index(biggest_element)-1) if it is not out of bound.

1 Like

Yeah I also did the same.