結果
| 問題 | 
                            No.2055 12x34...
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-09-18 01:32:16 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 434 ms / 2,000 ms | 
| コード長 | 278 bytes | 
| コンパイル時間 | 562 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 56,240 KB | 
| 最終ジャッジ日時 | 2024-12-22 01:04:52 | 
| 合計ジャッジ時間 | 10,937 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 41 | 
ソースコード
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))
mod = 998244353
ans = 0
DP = defaultdict(int)
for a in A:
    DP[a] += DP[a - 1] + 1
    DP[a] %= mod
for cnt in DP.values():
    ans += cnt
    ans %= mod
ans -= n
ans %= mod
print(ans)