結果

問題 No.2036 Max Middle
ユーザー titiatitia
提出日時 2022-08-14 02:46:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 430 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 11,872 KB
実行使用メモリ 34,476 KB
最終ジャッジ日時 2023-10-25 10:25:14
合計ジャッジ時間 5,491 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,080 KB
testcase_01 AC 30 ms
10,080 KB
testcase_02 AC 31 ms
10,080 KB
testcase_03 AC 30 ms
10,080 KB
testcase_04 AC 30 ms
10,080 KB
testcase_05 AC 30 ms
10,080 KB
testcase_06 AC 29 ms
10,080 KB
testcase_07 AC 31 ms
10,144 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