結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,764 KB
testcase_01 AC 16 ms
7,832 KB
testcase_02 AC 16 ms
7,764 KB
testcase_03 AC 16 ms
7,920 KB
testcase_04 AC 16 ms
7,760 KB
testcase_05 AC 16 ms
7,784 KB
testcase_06 AC 16 ms
7,732 KB
testcase_07 AC 16 ms
7,928 KB
testcase_08 AC 15 ms
7,820 KB
testcase_09 AC 16 ms
7,752 KB
testcase_10 AC 121 ms
18,672 KB
testcase_11 AC 129 ms
19,464 KB
testcase_12 AC 41 ms
10,608 KB
testcase_13 AC 96 ms
15,784 KB
testcase_14 AC 107 ms
17,272 KB
testcase_15 AC 69 ms
13,496 KB
testcase_16 AC 23 ms
8,812 KB
testcase_17 AC 110 ms
17,436 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 130 ms
19,788 KB
testcase_24 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = [int(i) for i in input().split(" ")]

unique = [1, ]
for i in range(1, n):
    if a[i] == a[i - 1]:
        unique[-1] += 1
    else:
        unique.append(1)

if len(unique) == 1:
    print(unique[0])

dp = [0] * (len(unique) + 1)
dp[0] = 0
dp[1] = unique[0]
dp[2] = unique[1]

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

print(max(dp))
0