結果
問題 | No.3017 交互浴 |
ユーザー |
![]() |
提出日時 | 2025-01-25 14:09:50 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 196 ms / 2,000 ms |
コード長 | 641 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 82,172 KB |
実行使用メモリ | 104,836 KB |
最終ジャッジ日時 | 2025-01-25 23:09:43 |
合計ジャッジ時間 | 14,939 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge11 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 55 |
ソースコード
from collections import deque N = int(input()) H = list(map(int, input().split())) color = deque([[0, 10**9+1]]) 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)