結果

問題 No.921 ずんだアロー
ユーザー TakoKurageTakoKurage
提出日時 2019-11-10 04:58:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 232 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 10,500 KB
実行使用メモリ 19,608 KB
最終ジャッジ日時 2023-10-13 07:38:59
合計ジャッジ時間 2,787 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,092 KB
testcase_01 AC 16 ms
8,120 KB
testcase_02 AC 16 ms
8,148 KB
testcase_03 AC 16 ms
8,192 KB
testcase_04 AC 16 ms
8,116 KB
testcase_05 AC 16 ms
8,096 KB
testcase_06 AC 16 ms
8,208 KB
testcase_07 AC 16 ms
8,176 KB
testcase_08 AC 16 ms
8,184 KB
testcase_09 AC 16 ms
8,132 KB
testcase_10 AC 126 ms
18,640 KB
testcase_11 AC 136 ms
19,404 KB
testcase_12 AC 42 ms
10,552 KB
testcase_13 AC 101 ms
15,696 KB
testcase_14 AC 111 ms
16,608 KB
testcase_15 AC 74 ms
13,512 KB
testcase_16 AC 24 ms
8,876 KB
testcase_17 AC 115 ms
16,980 KB
testcase_18 AC 47 ms
19,600 KB
testcase_19 AC 46 ms
19,492 KB
testcase_20 AC 47 ms
19,604 KB
testcase_21 AC 48 ms
19,592 KB
testcase_22 AC 48 ms
19,608 KB
testcase_23 AC 138 ms
19,532 KB
testcase_24 AC 47 ms
19,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import groupby

N, *A = map(int, open(0).read().split())

G = [len(tuple(v)) for _, v in groupby(A)]

dp = [0] * (len(G) + 2)
for i, g in enumerate(G):
    dp[i + 2] = max(dp[i] + g, dp[i + 1] + g - 1)

print(dp[-1])
0