問題一覧 > 通常問題

No.2485 Add to Variables (Another)

レベル : / AI推定難易度 : 2275 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 36
作問者 : ytqm3 / テスター : Magentor
お気に入りにしたユーザー ProblemId : 10114 / 自分の提出
問題文最終更新日: 2023-09-22 21:45:16
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 405 技術室奥プログラミングコンテスト#7 Day1 (順位表) の他の問題:
Problems F and G share the same setting and differ only in their constraints.

Problem Statement

There is a sequence $A$ of length $N$. Initially, all values of $A$ are $0$.

Consider performing the following $4$ types of operations on this sequence.

  • Do nothing.
  • Choose an integer $k \ (1 \leq k \leq N-1)$ and, for every integer $i$ satisfying $1 \leq i \leq k$, add $1$ to $A_i$.
  • Choose an integer $k \ (2 \leq k \leq N)$ and, for every integer $i$ satisfying $k \leq i \leq N$, add $1$ to $A_i$.
  • For every integer $i$ satisfying $1 \leq i \leq N$, add $1$ to $A_i$.

Among the ways to perform exactly $M$ operations, find the number of those resulting in $A=B$, modulo $998244353$.

Here, two sequences of operations are considered different if and only if there exists an integer $i$ such that the sets of indices of the elements to which $1$ is added in the $i$-th operation differ.

Input

The input is given from Standard Input in the following format.

$N$ $M$
$B_1$ $B_2$ $\ldots$ $B_N$
  • All input values are integers.
  • $1 \leq N,M \leq 1000$
  • $0 \leq B_i \leq M$
  • Output

    Output the answer.

    Sample

    Sample 1
    Input
    4 2
    1 1 1 0
    
    Output
    2
    

    In the $1$-st operation, add $1$ to $A_1,A_2,A_3$, and in the $2$-nd operation, do not add $1$ to any variable; or, in the $1$-st operation, do not add $1$ to any variable, and in the $2$-nd operation, add $1$ to $A_1,A_2,A_3$. These $2$ ways are possible.

    Sample 2
    Input
    4 2
    1 1 1 1
    
    Output
    8
    
    $A_1=A_2=A_3=A_4=1$ can be achieved only when adding $1$ to the variables to which $1$ was not added in the $1$-st operation, so the answer is $8$ ways.
    Sample 3
    Input
    4 3
    0 3 2 2
    
    Output
    0
    
    Sample 4
    Input
    4 314
    202 3 9 22
    
    Output
    362672301
    
    Sample 5
    Input
    1 1
    1
    
    Output
    1
    

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