結果
| 問題 |
No.3017 交互浴
|
| コンテスト | |
| ユーザー |
kidodesu
|
| 提出日時 | 2025-01-25 13:13:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 203 ms / 2,000 ms |
| コード長 | 485 bytes |
| コンパイル時間 | 597 ms |
| コンパイル使用メモリ | 82,880 KB |
| 実行使用メモリ | 107,564 KB |
| 最終ジャッジ日時 | 2025-01-25 22:38:19 |
| 合計ジャッジ時間 | 15,167 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge8 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 55 |
ソースコード
n = int(input())
H = list(map(int, input().split()))
now = 0
inf = float("INF")
stuck = [(inf, 1)]
for i in range(n):
h = H[i]
while stuck[-1][0] <= h:
x, t = stuck.pop()
if t:
now += x
else:
now -= x
if i % 2:
if not stuck[-1][1]:
now -= h
stuck.append((h, 1))
else:
if stuck[-1][1]:
now += h
stuck.append((h, 0))
print(now)
kidodesu