結果
| 問題 |
No.2036 Max Middle
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-12 21:50:09 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 524 bytes |
| コンパイル時間 | 261 ms |
| コンパイル使用メモリ | 82,156 KB |
| 実行使用メモリ | 121,348 KB |
| 最終ジャッジ日時 | 2024-09-23 02:09:27 |
| 合計ジャッジ時間 | 4,346 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 TLE * 1 -- * 12 |
ソースコード
from heapq import heappush,heappop
n = int(input())
A = list(map(int,input().split()))
num = A[:]
done = [0]*n
h = []
for i,a in enumerate(A):
heappush(h,[-a,i])
ans = 0
while h:
c,ind = heappop(h)
# print(c,ind)
c = -c
if ind == 0 or ind == n-1:
done[ind] = 1
num[ind] = c
continue
if done[ind-1] == done[ind+1] == 0:
ans += 1
c = min(num[ind-1],num[ind+1])-1
num[ind] = c
heappush(h,[-c,ind])
else:
done[ind] = 1
print(ans)