結果

問題 No.2036 Max Middle
ユーザー prussian_coderprussian_coder
提出日時 2022-08-12 22:38:47
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 295 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 81,820 KB
実行使用メモリ 99,268 KB
最終ジャッジ日時 2023-10-24 10:55:09
合計ジャッジ時間 4,511 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

N=int(input())
A=[int(x) for x in input().split()]
import heapq
q=[]
for i in range(N):
	heapq.heappush(q,(-A[i],i))
ans=0
while q:
	c,x=heapq.heappop(q)
	if x==0 or x==N-1:
		continue
	if A[x-1]<A[x] and A[x]>A[x+1]:
		A[x]=min(A[x-1],A[x+1])-1
		heapq.heappush(q,(-A[x],x))
		ans+=1
print(ans)
0