結果
| 問題 |
No.2036 Max Middle
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 21:11:07 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 743 bytes |
| コンパイル時間 | 367 ms |
| コンパイル使用メモリ | 82,044 KB |
| 実行使用メモリ | 53,800 KB |
| 最終ジャッジ日時 | 2025-06-12 21:12:47 |
| 合計ジャッジ時間 | 4,489 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 TLE * 1 -- * 12 |
ソースコード
def max_operations():
import sys
input = sys.stdin.read().split()
n = int(input[0])
a = list(map(int, input[1:n+1]))
count = 0
i = 0
while i < n-2:
if a[i] < a[i+1] and a[i+1] > a[i+2]:
# Perform the operation
new_val = min(a[i], a[i+2]) - 1
a[i+1] = new_val
count += 1
# After operation, check if i can still be a peak or if i-1 became a peak
# We might need to check previous indices
if i > 0 and a[i-1] < a[i] and a[i] > a[i+1]:
i = max(i-1, 0)
continue
else:
i = max(i-1, 0)
continue
i += 1
print(count)
max_operations()
gew1fw