Logo
(追記) (追記ここまで)

25692번 - Mode 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 1024 MB311100.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.

제한

예제 입력 1

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

예제 출력 1

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ドル$.

출처

Camp > Petrozavodsk Programming Camp > Summer 2022 > Day 5: ZJU Contest 2 A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /