結果
| 問題 |
No.3017 交互浴
|
| コンテスト | |
| ユーザー |
koncha
|
| 提出日時 | 2025-01-25 13:58:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 561 bytes |
| コンパイル時間 | 238 ms |
| コンパイル使用メモリ | 82,772 KB |
| 実行使用メモリ | 512,652 KB |
| 最終ジャッジ日時 | 2025-01-25 23:04:46 |
| 合計ジャッジ時間 | 24,105 ms |
|
ジャッジサーバーID (参考情報) |
judge10 / judge11 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 WA * 45 RE * 3 TLE * 2 MLE * 1 |
ソースコード
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