結果

問題 No.921 ずんだアロー
ユーザー titia
提出日時 2019-11-08 22:01:20
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 23,732 KB
最終ジャッジ日時 2024-09-15 01:29:08
合計ジャッジ時間 3,035 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))
A.append("?")

NOW=-1
count=0
LIST=[]

for a in A:
    if NOW==a:
        count+=1
    else:
        LIST.append((NOW,count))
        NOW=a
        count=1

DP=[0]*len(LIST)

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

print(max(DP))
0