結果
| 問題 | No.3017 交互浴 |
| コンテスト | |
| ユーザー |
koncha
|
| 提出日時 | 2025-01-25 13:58:58 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 561 bytes |
| 記録 | |
| コンパイル時間 | 396 ms |
| コンパイル使用メモリ | 84,940 KB |
| 実行使用メモリ | 318,844 KB |
| 最終ジャッジ日時 | 2026-06-24 00:07:50 |
| 合計ジャッジ時間 | 14,117 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 WA * 42 RE * 3 TLE * 1 -- * 6 |
ソースコード
N = int(input())
H = list(map(int, input().split()))
color = [[0, 10**9]]
cnt = 0
for i, h in enumerate(H):
is_green = bool(i%2)
left = 0
idx = 0
while color[idx][1] <= h:
if idx % 2 == 0:
cnt += (color[idx][1] - color[idx][0]) * (-1 if is_green else 1)
idx += 1
if idx % 2 == 0:
cnt += (h - color[idx][0]) * (-1 if is_green else 1)
if color[idx][0] != h:
color = [[0, h], [h, color[idx][1]]] + color[idx+1:]
else:
color = [[0, color[idx][1]] + color[idx+1:]]
print(cnt)
koncha