結果
問題 |
No.3017 交互浴
|
ユーザー |
![]() |
提出日時 | 2025-01-25 14:08:39 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 639 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 82,376 KB |
実行使用メモリ | 104,688 KB |
最終ジャッジ日時 | 2025-01-25 23:09:01 |
合計ジャッジ時間 | 14,659 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 52 RE * 3 |
ソースコード
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] if color: c = color.popleft() for a in [[h, c[1]], [0, h]]: if a[0] != a[1]: color.appendleft(a) print(cnt)