結果

問題 No.921 ずんだアロー
コンテスト
ユーザー kou
提出日時 2019-11-08 21:42:01
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 367 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 288 ms
コンパイル使用メモリ 21,412 KB
実行使用メモリ 24,560 KB
最終ジャッジ日時 2026-08-27 15:13:38
合計ジャッジ時間 4,787 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from itertools import groupby

n, *a = map(int, open(0).read().split())
g = [len(list(g)) for k, g in groupby(a)]
ans1 = ans2 = 0
for i, v in enumerate(g):
	if i % 2:
		ans1 += v
		ans2 += max(v - 2, 0)
	else:
		ans1 += max(v - 2, 0)
		ans2 += v
if g[0] > 1:
	ans1 += 1
if g[-1] > 1 and len(g)>1:
	if len(g) % 2:
		ans1 += 1
	else:
		ans2 += 1
print(max(ans1, ans2))
0