結果
問題 |
No.921 ずんだアロー
|
ユーザー |
![]() |
提出日時 | 2025-06-12 14:13:38 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 545 bytes |
コンパイル時間 | 350 ms |
コンパイル使用メモリ | 82,228 KB |
実行使用メモリ | 89,856 KB |
最終ジャッジ日時 | 2025-06-12 14:13:43 |
合計ジャッジ時間 | 2,515 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 5 |
ソースコード
n = int(input()) a = list(map(int, input().split())) if n == 0: print(0) exit() # Split into runs runs = [] current = a[0] count = 1 for i in range(1, n): if a[i] == current: count += 1 else: runs.append(count) current = a[i] count = 1 runs.append(count) m = len(runs) if m == 0: print(0) elif m == 1: print(runs[0]) else: dp = [0] * m dp[0] = runs[0] dp[1] = max(runs[0], runs[1]) for i in range(2, m): dp[i] = max(dp[i-1], dp[i-2] + runs[i]) print(dp[m-1])