結果

問題 No.2055 12x34...
ユーザー ecottea
提出日時 2024-02-26 22:48:28
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 259 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 56,336 KB
最終ジャッジ日時 2024-09-29 11:47:16
合計ジャッジ時間 10,184 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))

MOD = 998244353

res = 0

d = defaultdict(int)

for i in range(n):
    c = d[a[i] - 1]
    res += c
    nc = (d[a[i]] + c + 1) % MOD
    d[a[i]] = nc

print(res % MOD)
0