結果

問題 No.921 ずんだアロー
ユーザー koukou
提出日時 2019-11-08 21:38:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 354 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 19,744 KB
最終ジャッジ日時 2023-10-13 03:38:55
合計ジャッジ時間 2,559 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,120 KB
testcase_01 WA -
testcase_02 AC 15 ms
8,220 KB
testcase_03 AC 16 ms
8,284 KB
testcase_04 AC 16 ms
8,140 KB
testcase_05 WA -
testcase_06 AC 16 ms
8,156 KB
testcase_07 AC 16 ms
8,128 KB
testcase_08 AC 16 ms
8,124 KB
testcase_09 AC 16 ms
8,252 KB
testcase_10 AC 121 ms
18,696 KB
testcase_11 WA -
testcase_12 AC 41 ms
10,532 KB
testcase_13 AC 96 ms
15,764 KB
testcase_14 AC 106 ms
17,344 KB
testcase_15 AC 69 ms
13,388 KB
testcase_16 AC 23 ms
8,944 KB
testcase_17 AC 109 ms
17,648 KB
testcase_18 WA -
testcase_19 AC 48 ms
19,528 KB
testcase_20 AC 47 ms
19,616 KB
testcase_21 AC 48 ms
19,544 KB
testcase_22 WA -
testcase_23 AC 131 ms
19,572 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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:
	if len(g) % 2:
		ans2 += 1
	else:
		ans1 += 1
print(max(ans1, ans2))
0