結果

問題 No.2625 Bouns Ai
ユーザー PNJPNJ
提出日時 2024-02-09 22:29:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 770 ms / 2,000 ms
コード長 764 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 227,700 KB
最終ジャッジ日時 2024-02-09 22:30:03
合計ジャッジ時間 15,789 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
61,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 88 ms
75,352 KB
testcase_03 AC 409 ms
218,792 KB
testcase_04 AC 742 ms
227,700 KB
testcase_05 AC 402 ms
220,888 KB
testcase_06 AC 384 ms
220,916 KB
testcase_07 AC 382 ms
220,888 KB
testcase_08 AC 411 ms
220,888 KB
testcase_09 AC 381 ms
218,796 KB
testcase_10 AC 732 ms
224,560 KB
testcase_11 AC 80 ms
64,344 KB
testcase_12 AC 730 ms
224,560 KB
testcase_13 AC 756 ms
225,056 KB
testcase_14 AC 731 ms
225,064 KB
testcase_15 AC 767 ms
225,072 KB
testcase_16 AC 770 ms
225,072 KB
testcase_17 AC 735 ms
225,064 KB
testcase_18 AC 764 ms
225,064 KB
testcase_19 AC 736 ms
225,072 KB
testcase_20 AC 758 ms
225,072 KB
testcase_21 AC 761 ms
225,064 KB
testcase_22 AC 737 ms
225,072 KB
testcase_23 AC 765 ms
225,048 KB
testcase_24 AC 743 ms
225,056 KB
testcase_25 AC 750 ms
225,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Map():
  return list(map(int,input().split()))

mod = 998244353
N = int(input())
A = Map()
S = 10**5
if N == 1:
  print(S + 1 - A[0])
  exit()
dp = [[0 for j in range(S + 2)] for i in range(N)]
for s in range(S + 1):
  if s + A[0] > S:
    break
  dp[0][s] += 1

for n in range(N-1):
  d = 0
  sss = S - A[n+1] + 1
  if A[n] - A[n+1] > 0:
    d += A[n] - A[n+1]
  for s in range(S+1):
    if n > 0 and s < S:
      dp[n][s+1] += dp[n][s]
      dp[n][s+1] %= mod
  for s in range(S+1):
    if s + d >= sss:
      break
    ss = s + d
    dp[n+1][ss] += dp[n][s]
    dp[n+1][ss] %= mod
    dp[n+1][sss] -= dp[n][s]
    dp[n+1][sss] %= mod
ans = 0
for s in range(S+1):
  dp[N-1][s+1] += dp[N-1][s]
  dp[N-1][s+1] %= mod
  ans += dp[N-1][s]
  ans %= mod
print(ans)
0