시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB59191639.024%

문제

You are given a multiset $s$ consisting of $n$ integers. You should perform the following three-step operation some number of times until a single integer remains in $s$.

  • Choose a multiset $t$ such that $t \subseteq s$ and $|t| \ge 2$.
  • Erase the elements of $t$ from $s$.
  • Insert $\max(t) - \min(t)$ to $s$.

Find a sequence of operations that maximizes the integer left in $s$.

입력

The first line contains a single integer $n$ $(2 \le n \le 10^5)$.

The second line contains $n$ integers $s_1, s_2, \ldots, s_n$ $(0 \le s_i \le 10^5)$.

출력

On the first line, print a single integer $k$ $(1 \le k \le n-1)$, the number of operations.

On each of the next $k$ lines, print an integer $m$ $(2 \le m \le n)$, the size of the chosen multiset $t$, followed by $m$ integers, $t_1, t_2, \ldots, t_m$.

Note that the operations are executed in the same order they are listed. So, for each operation, $t$ must be a subset of $s$ when all the preceding operations are performed.

서브태스크

번호배점제한
110

$s_{i+1} = s_i + 1$ (for all $1 \le i \le n - 1$)

240

$n \le 100, s_i \le 1000$ (for all $1 \le i \le n$)

350

No additional constraints.

예제 입력 1

7
33 24 63 48 97 90 93

예제 출력 1

4
3 33 93 90
2 63 60
2 48 24
3 97 24 3

노트

The sample does the following operations:

  Chosen $t$ New $s$
$0$   $\{24, 33, 48, 63, 90, 93, 97\}$
$1$ $\{33, 90, 93\}$ $\{24, 48, \underline{60}, 63, 97\}$
$2$ $\{60, 63\}$ $\{\underline{3}, 24, 48, 97\}$
$3$ $\{24, 48\}$ $\{3, \underline{24}, 97\}$
$4$ $\{3, 24, 97\}$ $\{\underline{94}\}$

The values underlined in $s$ denote the integer inserted. After the fourth operation, $s$ is reduced to a single integer value of $94$. It can be shown that no other sequence of operations results in a larger value.

출처

University > KAIST > 2023 KAIST RUN Spring Contest G번

채점 및 기타 정보

  • 예제는 채점하지 않는다.