結果

問題 No.2036 Max Middle
ユーザー 👑 KazunKazun
提出日時 2022-08-12 21:49:44
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 359 bytes
コンパイル時間 405 ms
コンパイル使用メモリ 81,620 KB
実行使用メモリ 101,988 KB
最終ジャッジ日時 2023-10-24 09:34:28
合計ジャッジ時間 5,201 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,456 KB
testcase_01 AC 42 ms
53,416 KB
testcase_02 AC 41 ms
53,416 KB
testcase_03 AC 41 ms
53,416 KB
testcase_04 AC 41 ms
53,416 KB
testcase_05 AC 41 ms
53,416 KB
testcase_06 AC 42 ms
53,416 KB
testcase_07 AC 44 ms
53,416 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

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

S=set([i for i in range(1,N-1) if A[i-1]<A[i] and A[i]>A[i+1]])

X=0
while S:
    i=S.pop()
    X+=1
    A[i]=min(A[i-1],A[i+1])-1

    if (i>=2) and A[i-2]<A[i-1] and A[i-1]>A[i]:
        S.add(i-1)

    if i<=N-3 and A[i]<A[i+1] and A[i+1]>A[i+2]:
        S.add(i+1)

print(X)
0