結果
| 問題 |
No.2036 Max Middle
|
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2022-08-12 21:49:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 359 bytes |
| コンパイル時間 | 274 ms |
| コンパイル使用メモリ | 82,556 KB |
| 実行使用メモリ | 104,848 KB |
| 最終ジャッジ日時 | 2024-09-23 02:08:45 |
| 合計ジャッジ時間 | 4,522 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 TLE * 1 -- * 12 |
ソースコード
from collections import deque
N=int(input())
A=list(map(int,input().split()))
S=set([i for i in range(1,N-1) if A[i-1]<A[i] and A[i]>A[i+1]])
X=0
while S:
i=S.pop()
X+=1
A[i]=min(A[i-1],A[i+1])-1
if (i>=2) and A[i-2]<A[i-1] and A[i-1]>A[i]:
S.add(i-1)
if i<=N-3 and A[i]<A[i+1] and A[i+1]>A[i+2]:
S.add(i+1)
print(X)
Kazun