結果

問題 No.921 ずんだアロー
ユーザー flippergoflippergo
提出日時 2020-12-25 20:17:40
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 257 bytes
コンパイル時間 498 ms
コンパイル使用メモリ 81,888 KB
実行使用メモリ 82,688 KB
最終ジャッジ日時 2023-10-23 20:07:34
合計ジャッジ時間 3,270 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,308 KB
testcase_01 AC 37 ms
53,308 KB
testcase_02 AC 35 ms
53,308 KB
testcase_03 AC 35 ms
53,308 KB
testcase_04 AC 36 ms
53,308 KB
testcase_05 AC 36 ms
53,308 KB
testcase_06 AC 37 ms
53,308 KB
testcase_07 AC 36 ms
53,308 KB
testcase_08 AC 37 ms
53,308 KB
testcase_09 AC 36 ms
53,308 KB
testcase_10 AC 65 ms
80,884 KB
testcase_11 AC 63 ms
82,620 KB
testcase_12 AC 47 ms
65,160 KB
testcase_13 AC 57 ms
75,564 KB
testcase_14 AC 58 ms
77,104 KB
testcase_15 AC 53 ms
71,964 KB
testcase_16 AC 45 ms
62,016 KB
testcase_17 AC 60 ms
78,536 KB
testcase_18 AC 60 ms
82,536 KB
testcase_19 AC 66 ms
82,536 KB
testcase_20 AC 65 ms
82,516 KB
testcase_21 AC 59 ms
82,516 KB
testcase_22 AC 60 ms
82,516 KB
testcase_23 AC 62 ms
82,688 KB
testcase_24 AC 60 ms
82,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
dp = [0 for _ in range(N)]
dp[0]=1
for i in range(1,N):
    if A[i]==A[i-1]:
        dp[i] = dp[i-1]+1
    else:
        dp[i]=dp[i-1]
        if i>=2:
            dp[i]=max(dp[i],dp[i-2]+1)
print(dp[N-1])
0