結果
問題 |
No.2055 12x34...
|
ユーザー |
|
提出日時 | 2022-09-18 01:29:22 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 453 bytes |
コンパイル時間 | 432 ms |
コンパイル使用メモリ | 82,596 KB |
実行使用メモリ | 128,348 KB |
最終ジャッジ日時 | 2024-12-22 01:04:40 |
合計ジャッジ時間 | 8,902 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | WA * 41 |
ソースコード
from collections import defaultdict n = int(input()) A = list(map(int, input().split())) mod = 998244353 ans = 0 N_cnt = defaultdict(int) for i in range(n): a = A[i] N_cnt[a] += 1 C = [(num, cnt) for num, cnt in N_cnt.items()] C.sort(key=lambda x: -x[0]) res = 0 ans = 0 for i in range(len(C) - 1): if C[i][0] - 1 == C[i + 1][0]: res += C[i][1] res %= mod else: res = 0 ans += res ans %= mod print(ans)