RRCOPY - Wrong answer

I already looked up the other submissions and I know that my code is the slow way to solve this problem, but it is certainly not the wrong answer. I have checked my answers in the debug with TONS of test trials, and all of them yield correct answers. Take a look.

Why am I receiving a wrong answer if I have checked this so many times in the debug?

some trials I did:

Input:

5

9

1 1 1 1 1 1 1 1 1

9

1 2 3 4 5 6 7 8 9

9

9 8 7 6 5 4 3 2 1

9

1 2 3 1 2 3 1 2 3

9

3 2 1 3 2 1 3 2 1

Output:

1

9

9

3

3

  • I also used long integers to avoid any overflow

your algorithm is correct but it leads to TLE you can do this in O(N) and your answer is wrong because you are not printing ā€˜\nā€™ after outputing your answer(that is new line) after answer and if you include that also it will lead to TLE. Thank you happy coding :slight_smile:

2 Likes
//