結果

問題 No.921 ずんだアロー
ユーザー TakoKurageTakoKurage
提出日時 2019-11-08 23:37:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 271 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 10,708 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2023-10-13 05:23:54
合計ジャッジ時間 2,910 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,212 KB
testcase_01 AC 15 ms
8,300 KB
testcase_02 AC 15 ms
8,248 KB
testcase_03 AC 16 ms
8,212 KB
testcase_04 AC 16 ms
8,240 KB
testcase_05 AC 16 ms
8,100 KB
testcase_06 AC 16 ms
8,160 KB
testcase_07 AC 16 ms
8,108 KB
testcase_08 AC 15 ms
8,280 KB
testcase_09 AC 16 ms
8,228 KB
testcase_10 AC 171 ms
18,752 KB
testcase_11 AC 179 ms
19,400 KB
testcase_12 AC 51 ms
10,648 KB
testcase_13 AC 131 ms
16,288 KB
testcase_14 AC 149 ms
17,236 KB
testcase_15 AC 95 ms
13,392 KB
testcase_16 AC 26 ms
8,832 KB
testcase_17 AC 152 ms
17,572 KB
testcase_18 AC 48 ms
19,556 KB
testcase_19 AC 47 ms
19,712 KB
testcase_20 AC 47 ms
19,536 KB
testcase_21 AC 46 ms
19,528 KB
testcase_22 AC 46 ms
19,528 KB
testcase_23 AC 183 ms
19,576 KB
testcase_24 AC 47 ms
19,648 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 + 1] = max(dp[i + 1], dp[i] + g - 1)
    dp[i + 2] = max(dp[i + 2], dp[i] + g)

print(max(dp))
0