結果

問題 No.921 ずんだアロー
ユーザー lloyzlloyz
提出日時 2022-03-28 00:50:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 172 ms / 2,000 ms
コード長 260 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 20,856 KB
最終ジャッジ日時 2024-04-24 10:22:53
合計ジャッジ時間 3,151 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,624 KB
testcase_01 AC 26 ms
10,624 KB
testcase_02 AC 26 ms
10,752 KB
testcase_03 AC 25 ms
10,624 KB
testcase_04 AC 24 ms
10,624 KB
testcase_05 AC 24 ms
10,624 KB
testcase_06 AC 24 ms
10,624 KB
testcase_07 AC 25 ms
10,624 KB
testcase_08 AC 25 ms
10,752 KB
testcase_09 AC 25 ms
10,624 KB
testcase_10 AC 118 ms
19,716 KB
testcase_11 AC 119 ms
20,848 KB
testcase_12 AC 46 ms
13,056 KB
testcase_13 AC 94 ms
17,136 KB
testcase_14 AC 100 ms
18,452 KB
testcase_15 AC 72 ms
15,516 KB
testcase_16 AC 31 ms
11,136 KB
testcase_17 AC 105 ms
18,588 KB
testcase_18 AC 163 ms
20,728 KB
testcase_19 AC 166 ms
20,604 KB
testcase_20 AC 167 ms
20,736 KB
testcase_21 AC 165 ms
20,732 KB
testcase_22 AC 171 ms
20,856 KB
testcase_23 AC 126 ms
20,528 KB
testcase_24 AC 172 ms
20,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))

DP = [0 for i in range(n)]
DP[0] = DP[1] = 1
for i in range(1, n):
    if A[i] == A[i - 1]:
        DP[i] = max(DP[i], DP[i - 1] + 1)
    if i > 1:
        DP[i] = max(DP[i], DP[i - 2] + 1)
print(DP[n - 1])
0