結果

問題 No.921 ずんだアロー
ユーザー hir355hir355
提出日時 2020-04-03 20:51:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 385 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 10,812 KB
実行使用メモリ 19,836 KB
最終ジャッジ日時 2023-09-16 00:06:24
合計ジャッジ時間 4,027 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,772 KB
testcase_01 AC 16 ms
7,860 KB
testcase_02 AC 16 ms
7,784 KB
testcase_03 AC 16 ms
7,908 KB
testcase_04 AC 16 ms
7,864 KB
testcase_05 AC 16 ms
7,816 KB
testcase_06 AC 16 ms
7,868 KB
testcase_07 AC 16 ms
7,684 KB
testcase_08 AC 16 ms
7,740 KB
testcase_09 AC 17 ms
7,784 KB
testcase_10 AC 158 ms
18,720 KB
testcase_11 AC 164 ms
19,228 KB
testcase_12 AC 49 ms
10,644 KB
testcase_13 AC 122 ms
15,764 KB
testcase_14 AC 137 ms
17,216 KB
testcase_15 AC 87 ms
13,396 KB
testcase_16 AC 26 ms
8,816 KB
testcase_17 AC 143 ms
17,344 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 166 ms
19,504 KB
testcase_24 AC 86 ms
19,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
l = []
i = 0
while i < n:
    cnt = 1
    while i < n - 1 and a[i] == a[i + 1]:
        cnt += 1
        i += 1
    l.append(cnt)
    i += 1
m = len(l)
dp = [[0] * (m + 1) for _ in range(2)]
dp[0][0] = 0
for i in range(m):
    dp[1][i + 1] = dp[0][i] + l[i]
    dp[0][i + 1] = max(dp[0][i], dp[1][i])
print(max(dp[0][m], dp[1][m]))
0