Moony And ICPC Team

Why Iam Getting WA

I guess you’re missing out on the fact that they are standing in a circle. So you need to take cases where you take some array elements from the end and some from the beginning.

Also, since you’re using int datatype, your solution will fail for cases where your sum exceeds INT_MAX. For example 1e9 + 1e9 + 1e9.

1 Like

I have even tried long long and double

Thanks!! I missed out that they are standing on a circle

I’m also getting wrong answer.Could you please tell me what’s wrong in my code.


I think you’re taking 5 consecutive elements and then taking the maximum three out of it. In that case, you might end up selecting two people who are not friends. For eg-
20 10 10 20 20
In this case, you’ll select all the 20’s. But index 3 or 4 are not friends with index 0.

1 Like