In the first test case, you can color the array as follows: [5,4,5]. Your score is max([5,5])+size([5,5])=5+2=7. This is the maximum score you can get.
In the second test case, you can color the array as follows: [4,5,4]. Your score is max([4,4])+size([4,4])=4+2=6. This is the maximum score you can get.
In the third test case, you can color the array as follows: [3,3,3,3,4,1,2,3,4,5]. Your score is max([3,3,4,3,5])+size([3,3,4,3,5])=5+5=10. This is the maximum score you can get.
源码:
In the first test case, you can color the array as follows: $[\color{red}{5}, \color{black}{4}, \color{red}{5}]$. Your score is $\max([5, 5]) + \text{size}([5, 5]) = 5+2 = 7$. This is the maximum score you can get.
In the second test case, you can color the array as follows: $[\color{red}{4}, \color{black}{5}, \color{red}{4}]$. Your score is $\max([4, 4]) + \text{size}([4, 4]) = 4+2 = 6$. This is the maximum score you can get.
In the third test case, you can color the array as follows: $[\color{red}{3}, \color{black}{3}, \color{red}{3}, \color{black}{3}, \color{red}{4}, \color{black}{1}, \color{black}{2}, \color{red}{3}, \color{black}{4}, \color{red}{5}]$. Your score is $\max([3, 3, 4, 3, 5]) + \text{size}([3, 3, 4, 3, 5]) = 5+5 = 10$. This is the maximum score you can get.