結果

問題 No.921 ずんだアロー
ユーザー stngstng
提出日時 2022-08-14 20:36:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 275 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,208 KB
最終ジャッジ日時 2024-04-08 20:52:46
合計ジャッジ時間 2,243 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,332 KB
testcase_01 AC 35 ms
53,332 KB
testcase_02 AC 35 ms
53,332 KB
testcase_03 AC 36 ms
53,332 KB
testcase_04 AC 35 ms
53,332 KB
testcase_05 AC 35 ms
53,332 KB
testcase_06 AC 37 ms
53,332 KB
testcase_07 AC 35 ms
53,332 KB
testcase_08 AC 35 ms
53,332 KB
testcase_09 AC 35 ms
53,332 KB
testcase_10 AC 55 ms
74,140 KB
testcase_11 AC 56 ms
75,168 KB
testcase_12 AC 45 ms
62,732 KB
testcase_13 AC 52 ms
72,108 KB
testcase_14 AC 53 ms
73,068 KB
testcase_15 AC 48 ms
67,776 KB
testcase_16 AC 42 ms
61,968 KB
testcase_17 AC 54 ms
73,848 KB
testcase_18 AC 54 ms
75,208 KB
testcase_19 AC 55 ms
75,208 KB
testcase_20 AC 54 ms
75,208 KB
testcase_21 AC 55 ms
75,208 KB
testcase_22 AC 54 ms
75,208 KB
testcase_23 AC 55 ms
75,176 KB
testcase_24 AC 54 ms
75,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [0]*n
dp[0] = 1
if a[0] == a[1]:
    dp[1] = 2
else:
    dp[1] = 1

for i in range(2,n):
    if a[i-1] == a[i]:
        dp[i] = max(dp[i-1],dp[i-2])+1
    else:
        dp[i] = max(dp[i-1],dp[i-2]+1)
print(dp[n-1])
0