結果
| 問題 |
No.921 ずんだアロー
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 15:09:36 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 813 bytes |
| コンパイル時間 | 175 ms |
| コンパイル使用メモリ | 82,716 KB |
| 実行使用メモリ | 101,860 KB |
| 最終ジャッジ日時 | 2025-06-12 15:09:41 |
| 合計ジャッジ時間 | 2,637 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 7 |
ソースコード
n = int(input())
a = list(map(int, input().split()))
# Calculate max_same
from collections import defaultdict
max_same = 0
current_val = None
current_length = 0
count = defaultdict(int)
for num in a:
if num == current_val:
current_length += 1
else:
if current_val is not None:
count[current_val] += current_length
current_val = num
current_length = 1
# Add the last segment
if current_val is not None:
count[current_val] += current_length
if count:
max_same = max(count.values())
else:
max_same = 0
# Calculate max_non_adjacent using House Robber approach
prev1, prev2 = 0, 0
for _ in a:
current = max(prev1, prev2 + 1)
prev2, prev1 = prev1, current
max_non_adjacent = prev1
# Determine the answer
print(max(max_same, max_non_adjacent))
gew1fw