結果
| 問題 |
No.2036 Max Middle
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 14:08:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 711 bytes |
| コンパイル時間 | 222 ms |
| コンパイル使用メモリ | 82,500 KB |
| 実行使用メモリ | 284,900 KB |
| 最終ジャッジ日時 | 2025-06-12 14:08:19 |
| 合計ジャッジ時間 | 4,722 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 TLE * 1 -- * 12 |
ソースコード
import sys
from collections import deque
def main():
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
if n < 3:
print(0)
return
q = deque()
for i in range(n-2):
if a[i] < a[i+1] and a[i+1] > a[i+2]:
q.append(i)
count = 0
while q:
i = q.popleft()
if i < 0 or i >= n-2:
continue
if a[i] < a[i+1] and a[i+1] > a[i+2]:
count += 1
new_val = min(a[i], a[i+2]) - 1
a[i+1] = new_val
for next_i in [i-1, i+1]:
if 0 <= next_i <= n-3:
q.append(next_i)
print(count)
if __name__ == "__main__":
main()
gew1fw