Note
In the first test case, you can color the array as follows: [5,4,5]. Your score is max([5,5])+min([5,5])+size([5,5])=5+5+2=12. 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([5])+min([5])+size([5])=5+5+1=11. 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,5,4]. Your score is max([3,3,4,3,4])+min([3,3,4,3,4])+size([3,3,4,3,4])=4+3+5=12. This is the maximum score you can get.
源码:
**Note**
In the first test case, you can color the array as follows: $[\color{red}{5}, \color{black}{4}, \color{red}{5}\color{black}{]}$. Your score is $\max([5, 5]) + \min([5, 5]) + \text{size}([5, 5]) = 5+5+2 = 12$. This is the maximum score you can get.
In the second test case, you can color the array as follows: $[\color{black}{4}, \color{red}{5}, \color{black}{4}]$. Your score is $\max([5]) + \min([5]) + \text{size}([5]) = 5+5+1 = 11$. 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}{5}, \color{red}{4}\color{black}{]}$. Your score is $\max([3, 3, 4, 3, 4]) + \min([3, 3, 4, 3, 4]) + \text{size}([3, 3, 4, 3, 4]) = 4+3+5 = 12$. This is the maximum score you can get.