結果

問題 No.2036 Max Middle
ユーザー gew1fw
提出日時 2025-06-12 14:08:47
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 456 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 82,080 KB
実行使用メモリ 106,864 KB
最終ジャッジ日時 2025-06-12 14:08:54
合計ジャッジ時間 4,407 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 4 TLE * 1 -- * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

def max_operations():
    import sys
    input = sys.stdin.read().split()
    n = int(input[0])
    a = list(map(int, input[1:n+1]))
    
    ops = 0
    i = 0
    while i <= n-3:
        if a[i] < a[i+1] and a[i+1] > a[i+2]:
            min_val = min(a[i], a[i+2])
            a[i+1] = min_val - 1
            ops += 1
            i = max(i-1, 0)  # 检查前面的位置是否满足条件
        else:
            i += 1
    print(ops)

max_operations()
0