| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3 초 (추가 시간 없음) | 1024 MB | 3 | 1 | 1 | 100.000% |
You are given an array $a$ of length $n$. Define $\mathit{cnt}_x$ as the number of occurrences of $x$ in $a$.
Now you can do the following operation at most once: select a non-empty subarray $a_l, a_{l+1}, a_{l+2}, \ldots, a_r$ and an integer $k \in [-10^9, 10^9],ドル and add $k$ to all the elements in the subarray.
Your first task is to find the maximum possible value of $W = \max\{\mathit{cnt}_x \mid x \in \mathbb{Z}\}$ after one operation. Your second task is to find all $v$ such that $\mathit{cnt}_v = W$ can be achieved after one operation.
The first line contains an integer $T$ (1ドル \leq T \leq 20$), the number of test cases.
Each test case consists of two lines. The first line contains a single integer $n$ (2ドル \leq n \leq 2 \cdot 10^5$), and the second line contains $n$ integers denoting the array (1ドル \le a_i \le 10^9$).
It is guaranteed that $\sum n \leq 5 \cdot 10^5,ドル and $a_i$ are not all the same.
For each test case, output one integer on the first line, denoting the maximum value $W$. Then for all integers $v$ satisfying the condition, output them in ascending order.
4 5 1 2 3 2 1 5 1 1 3 1 1 6 2 4 2 4 8 8 5 1 2 3 4 5
4 1 5 1 4 2 4 8 2 1 2 3 4 5
The values of $W$ for the test cases are 4ドル,ドル 5ドル,ドル 4ドル,ドル 2ドル$.