結果

問題 No.921 ずんだアロー
ユーザー ptotqptotq
提出日時 2019-11-08 22:10:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 259 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,780 KB
実行使用メモリ 19,816 KB
最終ジャッジ日時 2023-10-13 03:53:40
合計ジャッジ時間 3,019 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,100 KB
testcase_01 AC 17 ms
8,292 KB
testcase_02 AC 16 ms
8,164 KB
testcase_03 AC 16 ms
8,228 KB
testcase_04 AC 16 ms
8,180 KB
testcase_05 AC 16 ms
8,132 KB
testcase_06 AC 17 ms
8,268 KB
testcase_07 AC 17 ms
8,192 KB
testcase_08 AC 17 ms
8,284 KB
testcase_09 AC 16 ms
8,284 KB
testcase_10 AC 180 ms
18,856 KB
testcase_11 AC 185 ms
19,424 KB
testcase_12 AC 54 ms
10,572 KB
testcase_13 AC 139 ms
16,152 KB
testcase_14 AC 155 ms
17,424 KB
testcase_15 AC 100 ms
13,668 KB
testcase_16 AC 28 ms
8,836 KB
testcase_17 AC 156 ms
17,400 KB
testcase_18 AC 49 ms
19,632 KB
testcase_19 AC 49 ms
19,816 KB
testcase_20 AC 49 ms
19,772 KB
testcase_21 AC 49 ms
19,708 KB
testcase_22 AC 49 ms
19,692 KB
testcase_23 AC 198 ms
19,528 KB
testcase_24 AC 50 ms
19,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import groupby
input()
_ = list(map(int, input().split()))
a = [len(tuple(v)) for _, v in groupby(_)]
N = len(a)
dp = [0]*(N+10)

for i in range(N):
    dp[i+1] = max(dp[i]+a[i]-1, dp[i+1])
    dp[i+2] = max(dp[i]+a[i], dp[i+2])

print(max(dp))
0