結果
| 問題 |
No.3017 交互浴
|
| コンテスト | |
| ユーザー |
koncha
|
| 提出日時 | 2025-01-25 14:05:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 617 bytes |
| コンパイル時間 | 344 ms |
| コンパイル使用メモリ | 82,616 KB |
| 実行使用メモリ | 105,568 KB |
| 最終ジャッジ日時 | 2025-01-25 23:06:43 |
| 合計ジャッジ時間 | 10,354 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 RE * 49 |
ソースコード
from collections import deque
N = int(input())
H = list(map(int, input().split()))
color = deque([[0, 10**9]])
cnt = 0
for i, h in enumerate(H):
is_green = bool(i%2)
left = 0
idx = 0
while color[0][1] <= h:
c = color.popleft()
if idx % 2 == 0:
cnt += (c[1] - c[0]) * (-1 if is_green else 1)
idx += 1
c = color.popleft()
if idx % 2 == 0:
cnt += (h - c[0]) * (-1 if is_green else 1)
else:
h = c[1]
c = color.popleft()
for a in [[h, c[1]], [0, h]]:
if a[0] != a[1]:
color.appendleft(a)
print(cnt)
koncha