結果

問題 No.921 ずんだアロー
ユーザー titiatitia
提出日時 2019-11-08 22:01:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 21,980 KB
最終ジャッジ日時 2023-10-13 03:51:10
合計ジャッジ時間 2,783 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,808 KB
testcase_01 AC 16 ms
7,780 KB
testcase_02 AC 15 ms
7,860 KB
testcase_03 AC 15 ms
7,788 KB
testcase_04 AC 15 ms
7,876 KB
testcase_05 AC 15 ms
7,876 KB
testcase_06 AC 16 ms
7,760 KB
testcase_07 AC 16 ms
7,828 KB
testcase_08 AC 15 ms
7,956 KB
testcase_09 AC 15 ms
7,868 KB
testcase_10 AC 148 ms
20,000 KB
testcase_11 AC 160 ms
21,428 KB
testcase_12 AC 45 ms
11,004 KB
testcase_13 AC 116 ms
17,480 KB
testcase_14 AC 131 ms
18,564 KB
testcase_15 AC 85 ms
14,532 KB
testcase_16 AC 25 ms
8,884 KB
testcase_17 AC 135 ms
19,260 KB
testcase_18 AC 58 ms
19,600 KB
testcase_19 AC 58 ms
19,712 KB
testcase_20 AC 59 ms
19,696 KB
testcase_21 AC 58 ms
19,704 KB
testcase_22 AC 59 ms
19,712 KB
testcase_23 AC 169 ms
21,980 KB
testcase_24 AC 59 ms
19,596 KB
権限があれば一括ダウンロードができます

ソースコード

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