아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Mode

시간 제한3초메모리 제한1024 MB

요약
한 번의 연산으로 부분 배열에 정수를 더한 뒤 어떤 값의 최대 등장 횟수와 그 값을 달성하는 모든 v를 구한다.
난이도

보통10점 중 7점

유형
배열, 해시맵, 누적 합
정답자
아직 제출이 없습니다

문제

You are given an array aa of length nn. Define cnt_x\mathit{cnt}\_x as the number of occurrences of xx in aa.

Now you can do the following operation at most once: select a non-empty subarray a_l,a_l+1,a_l+2,…,a_ra\_l, a\_{l+1}, a\_{l+2}, \ldots, a\_r and an integer k∈\[−109,109]k \in \[-10^9, 10^9], and add kk to all the elements in the subarray.

Your first task is to find the maximum possible value of W=max⁡cnt_x∣x∈ZW = \max\\{\mathit{cnt}\_x \mid x \in \mathbb{Z}\\} after one operation. Your second task is to find all vv such that cnt_v=W\mathit{cnt}\_v = W can be achieved after one operation.

입력

The first line contains an integer TT (1≤T≤201 \leq T \leq 20), the number of test cases.

Each test case consists of two lines. The first line contains a single integer nn (2≤n≤2⋅1052 \leq n \leq 2 \cdot 10^5), and the second line contains nn integers denoting the array (1≤a_i≤1091 \le a\_i \le 10^9).

It is guaranteed that ∑n≤5⋅105\sum n \leq 5 \cdot 10^5, and a_ia\_i are not all the same.

출력

For each test case, output one integer on the first line, denoting the maximum value WW. Then for all integers vv satisfying the condition, output them in ascending order.

힌트

The values of WW for the test cases are 44, 55, 44, 22.

예제1

  1. 예제 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
    
    예상 출력
    4
    1
    5
    1
    4
    2
    4
    8
    2
    1
    2
    3
    4
    5