結果

問題 No.2036 Max Middle
ユーザー titiatitia
提出日時 2022-08-14 02:47:13
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 430 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 81,484 KB
実行使用メモリ 105,544 KB
最終ジャッジ日時 2023-10-25 10:25:27
合計ジャッジ時間 4,949 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,408 KB
testcase_01 AC 37 ms
53,384 KB
testcase_02 AC 36 ms
53,384 KB
testcase_03 AC 36 ms
53,384 KB
testcase_04 AC 37 ms
53,384 KB
testcase_05 AC 37 ms
53,384 KB
testcase_06 AC 36 ms
53,384 KB
testcase_07 AC 37 ms
53,384 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 #

import sys
input = sys.stdin.readline
from heapq import heappop,heappush
from operator import itemgetter

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

H=[]

for i in range(N):
    H.append((-A[i],i))

H.sort(key=itemgetter(0))

ANS=0

while H:
    w,ind=heappop(H)

    if 1<=ind<N-1 and A[ind]>A[ind-1] and A[ind]>A[ind+1]:
        A[ind]=min(A[ind-1],A[ind+1])-1
        ANS+=1
        heappush(H,(-A[ind],ind))

print(ANS)
0