問題一覧 > 通常問題

No.3184 Make Same

レベル : / AI推定難易度 : 1500 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 94
作問者 : 蜜蜂 / テスター : Mitarushi
お気に入りにしたユーザー ProblemId : 12360 / 自分の提出
問題文最終更新日: 2025-06-15 12:53:52
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 471 (順位表) の他の問題:

Problem Statement

You are given a sequence of non-negative integers $A = (A_1, A_2, \cdots, A_N)$ of length $N$. Here, $A$ is guaranteed to be non-decreasing.
Your goal is to make all elements of $A$ equal. To do so, you may perform the following operation up to $30$ times.

  • Declare $3$ integers $l, r, v$ satisfying $1 \leq l \leq r \leq N, 0 \leq v \leq 10^9$.
  • Then, for $i = l, l + 1, \cdots, r$, replace $A_i$ with $A_i + v$.
  • Finally, sort $A$ in ascending order.
It can be proved that your goal can always be achieved under the constraints. Output one example of a sequence of operations that achieves the goal. Note that you do not need to minimize the number of operations.

Input

$N$
$A_1\ \ A_2\ \ \cdots A_N$

  • $1 \leq N \leq 2 \times 10^5$
  • $0 \leq A_i \leq 10^9$
  • $A_i \leq A_{i + 1}$
  • All inputs are integers.

Output

If the goal can be achieved with $M$ operations, first output $M$ on the $1$st line.
Then output $M$ lines. On the $i$-th line, output $l, r, v$ declared in the $i$-th operation, separated by spaces.

Sample

Sample 1
Input
4
1 3 4 6
Output
4
2 3 4
1 1 6
1 1 2
1 2 1

  • After the $1$st operation, $A = (1, 6, 7, 8)$.
  • After the $2$nd operation, $A = (6, 7, 7, 8)$.
  • After the $3$rd operation, $A = (7, 7, 8, 8)$.
  • After the $4$th operation, $A = (8, 8, 8, 8)$.

Sample 2
Input
1
0
Output
0

If the goal is already achieved from the start, the number of operations may be $0$.

Sample 3
Input
3
1 2 3
Output
4
3 3 997
1 1 999
1 1 998
1 3 0

In the end, $A = (1000, 1000, 1000)$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。