結果

問題 No.2055 12x34...
ユーザー ああいい
提出日時 2022-08-21 17:27:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 316 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 137,176 KB
最終ジャッジ日時 2024-10-10 06:17:10
合計ジャッジ時間 6,757 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))

from collections import defaultdict
ans = 0
P = 998244353

d = defaultdict(int)

for a in A:
    ans += d[a-1]
    d[a] += 1 + d[a-1]
    d[a] %= P
"""
d = defaultdict(int)
for a in A:
    ans += d[a + 1]
    d[a] += d[a + 1] + 1
    d[a] %= P
"""
print(ans % P)
0