結果
問題 |
No.2036 Max Middle
|
ユーザー |
![]() |
提出日時 | 2022-08-14 02:46:57 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 430 bytes |
コンパイル時間 | 98 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 37,636 KB |
最終ジャッジ日時 | 2024-09-25 05:26:33 |
合計ジャッジ時間 | 4,828 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)