結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,224 KB
testcase_01 AC 16 ms
8,176 KB
testcase_02 AC 17 ms
8,284 KB
testcase_03 AC 16 ms
8,172 KB
testcase_04 AC 16 ms
8,216 KB
testcase_05 AC 16 ms
8,128 KB
testcase_06 AC 17 ms
8,312 KB
testcase_07 AC 17 ms
8,264 KB
testcase_08 AC 16 ms
8,176 KB
testcase_09 AC 17 ms
8,188 KB
testcase_10 AC 124 ms
18,728 KB
testcase_11 WA -
testcase_12 AC 41 ms
10,528 KB
testcase_13 AC 94 ms
15,664 KB
testcase_14 AC 106 ms
17,280 KB
testcase_15 AC 70 ms
13,412 KB
testcase_16 AC 23 ms
8,956 KB
testcase_17 AC 110 ms
17,764 KB
testcase_18 AC 49 ms
19,604 KB
testcase_19 AC 49 ms
19,612 KB
testcase_20 AC 48 ms
19,568 KB
testcase_21 AC 49 ms
19,648 KB
testcase_22 AC 49 ms
19,596 KB
testcase_23 AC 133 ms
19,672 KB
testcase_24 AC 48 ms
19,684 KB
権限があれば一括ダウンロードができます

ソースコード

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