結果

問題 No.3017 交互浴
コンテスト
ユーザー norioc
提出日時 2025-03-20 00:56:17
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 392 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 236 ms
コンパイル使用メモリ 96,368 KB
実行使用メモリ 196,096 KB
最終ジャッジ日時 2026-07-07 06:46:24
合計ジャッジ時間 21,207 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 46 TLE * 1 -- * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def calc(st: list) -> int:
    res = 0
    l = 0
    for h, v in reversed(st):
        res += (h - l) * v
        l = h

    return res


INF = 1 << 60
N = int(input())
H = list(map(int, input().split()))

st = [(INF, 0)]
for i, h in enumerate(H):
    v = 1 if i % 2 == 0 else 0  # 1=水色

    while st[-1][0] <= h:
        st.pop()
    st.append((h, v))

    res = calc(st)
    print(res)
0