시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 (추가 시간 없음) | 1024 MB | 3 | 1 | 1 | 100.000% |
Grammy has a circular array $a_1, a_2, \ldots, a_n$. You can do the following operations several (possibly zero) times in any order:
After each time you do an operation successfully, Grammy will give you a candy. Meanwhile, the remaining parts of the array will be concatenated. For example, after deleting the third and fourth element of the array, the second element and the fifth element will become adjacent.
Find the maximum number of candies you can get.
Two positions $u$ and $v$ ($u<v$) are adjacent if and only if $u+1=v$ or $u=1$ and $v=L$, where $L$ is the length of the remaining array.
The first line contains two integers $n$ and $x$ ($1 \leq n \leq 10^5$, $1 \leq x \leq 10^9$) denoting the length of the array and the special number $x$.
The second line contains $n$ integers $a_1, a_2,\ldots, a_n$ ($1 \leq a_i \leq 10^9$) denoting the numbers in the circular array.
Output an integer denoting the maximum number of candies you can get.
6 5 1 1 4 5 1 4
2
10 5 1 2 5 2 1 2 3 4 8 4
3