Could someone tell me why I'm getting WA?

Problem Code:BTAR

Contest Code:COOK89

Check the following update to your solution.


Thank you for replying. I read the editorial which has the same approach as yours, I was trying to solve this using maps… could you tell me which test case my code fails?

Check the output of the following test.

1 1 1 1 1 1 1 2 3

Your code answer is 7, while the expected answer is 6.

1 Like

Thanks a lot, I just realised that I didn’t handle the cases with 1’s and 2’s remaining.