結果

問題 No.281 門松と魔法(1)
ユーザー n_knuu
提出日時 2015-09-19 15:06:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 586 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-11-06 19:35:16
合計ジャッジ時間 3,374 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 42 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import ceil
d = int(input())
H = [int(input()) for _ in range(3)]
if (H[0] < H[1] and H[1] > H[2]) or (H[0] > H[1] and H[1] < H[2]):
    print(0)
elif (H[1] == 0 and (H[0] == 0 or H[2] == 0)) or d == 0:
    print(-1)
else:
    ans = ceil(max(0, H[0]-H[1]) / d) + (H[0]-H[1] - ceil(max(0, H[0]-H[1]) / d) * d == 0) + ceil(max(0, H[2]-H[1]) / d) + (H[2]-H[1] - ceil(max(0, H[2]-H[1]) / d) * d == 0)
    if H[0] != 0 and H[2] != 0:
        ans = min(ans, ceil((H[1] - min(H[0], H[2])) / d) + (H[1] - min(H[0], H[2]) - ceil((H[1] - min(H[0], H[2])) / d) * d == 0))
    print(ans)
0