結果
| 問題 |
No.2036 Max Middle
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2022-08-14 02:47:13 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 430 bytes |
| コンパイル時間 | 173 ms |
| コンパイル使用メモリ | 82,044 KB |
| 実行使用メモリ | 108,868 KB |
| 最終ジャッジ日時 | 2024-09-25 05:26:43 |
| 合計ジャッジ時間 | 4,302 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 TLE * 1 -- * 12 |
ソースコード
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)
titia