結果

問題 No.3017 交互浴
コンテスト
ユーザー ntuda
提出日時 2025-10-18 00:23:58
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 120 ms / 2,000 ms
+ 994µs
コード長 315 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 80 ms
コンパイル使用メモリ 64,264 KB
実行使用メモリ 89,136 KB
最終ジャッジ日時 2026-10-21 11:05:19
合計ジャッジ時間 17,809 ms
ジャッジサーバーID
(参考情報)
judge6_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 57
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
H = list(map(int, input().split()))
X = [10 **9 + 1]
xlen = 1
tmp = 0
for i in range(N):
    h = H[i]
    while X[-1] <= h:
        tmp -= X.pop() * (-1) ** (xlen)
        xlen -= 1
    if xlen % 2 == (i + 1) % 2:
        X.append(h)
        xlen += 1
        tmp += h * (-1) ** (i)
    print(tmp)
0