問題一覧 > 通常問題

No.2275 →↑↓

レベル : / AI推定難易度 : 750 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 180
作問者 : miscalc / テスター : magsta
お気に入りにしたユーザー ProblemId : 9530 / 自分の提出
問題文最終更新日: 2023-04-22 00:13:11
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 385 (順位表) の他の問題:

Problem Statement

There is an infinitely large $2$-dimensional grid. Each cell is painted white or black. Specifically, for each $i = 1, 2, \ldots, N$, cells $(i, 1), (i, 2), \ldots, (i, A_i)$ are painted white, and all other cells are painted black.

Initially, Magusuta is at cell $(1, 1)$. He is trying to reach cell $(N, 1)$ by repeating the following action.

  • Let $(i, j)$ be the cell he is currently on. Paint cell $(i, j)$ black. Then, choose $1$ white cell among cells $(i + 1, j), (i, j + 1), (i, j - 1)$ and move to that cell.

Find the number of ways to reach cell $(N, 1)$, modulo $998244353$.

Input

$N$
$A_1$ $A_2$ $\ldots$ $A_N$

  • All input values are integers.
  • $2 \leq N \leq 2 \times 10^5$
  • $1 \leq A_i \leq 10^9$

Output

Print the number of ways to reach cell $(N, 1)$, modulo $998244353$. Print a newline at the end.

Sample

Sample 1
Input
3
1 3 2
Output
2

The cells painted white are $(1, 1), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2)$. There are the following $2$ ways to move.

  • $(1, 1) \to (2, 1) \to (3, 1)$
  • $(1, 1) \to (2, 1) \to (2, 2) \to (3, 2) \to (3, 1)$

Sample 2
Input
5
427547210 327546386 963298277 230265126 293165710
Output
538454432

Print the answer modulo $998244353$.

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