結果

問題 No.921 ずんだアロー
ユーザー vwxyzvwxyz
提出日時 2024-04-17 21:40:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 496 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 23,208 KB
最終ジャッジ日時 2024-04-17 21:40:07
合計ジャッジ時間 3,622 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,752 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 28 ms
10,752 KB
testcase_04 AC 27 ms
10,752 KB
testcase_05 AC 32 ms
10,752 KB
testcase_06 AC 31 ms
10,752 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 31 ms
10,752 KB
testcase_09 AC 31 ms
10,752 KB
testcase_10 AC 159 ms
21,420 KB
testcase_11 AC 138 ms
22,684 KB
testcase_12 AC 59 ms
13,568 KB
testcase_13 AC 97 ms
19,316 KB
testcase_14 AC 110 ms
20,084 KB
testcase_15 AC 78 ms
16,572 KB
testcase_16 AC 38 ms
11,392 KB
testcase_17 AC 126 ms
20,752 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 142 ms
23,208 KB
testcase_24 AC 67 ms
20,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Run_Length(lst):
    run_length=[]
    if lst:
        prev=lst[0]
        cnt=1
        for x in lst[1:]:
            if x==prev:
                cnt+=1
            else:
                run_length.append((prev,cnt))
                prev=x
                cnt=1
        run_length.append((prev,cnt))
    return run_length

N=int(input())
A=Run_Length(list(map(int,input().split())))
le=len(A)
inf=1<<30
dp0,dp1=0,-inf
for a,c in A:
    dp0,dp1=max(dp0,dp1),dp0+c
ans=max(dp0,dp1)
print(ans)
0