結果

問題 No.281 門松と魔法(1)
コンテスト
ユーザー eitaho
提出日時 2016-07-27 12:29:40
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
RE  
実行時間 -
コード長 444 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 354 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 20,572 KB
最終ジャッジ日時 2026-05-07 02:02:03
合計ジャッジ時間 8,558 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 47 RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

INF = 10 ** 9
d = int(input())


def calc(a, b, c):  # a < b < c
    fb = max(0, (b - c + 1 + d - 1) // d)
    b = max(0, b - d * fb)
    fa = max(0, (a - b + 1 + d - 1) // d)
    a = max(0, a - d * fa)
    return fa + fb if a < b < c else INF


H = [int(input()) for i in range(3)]
a = min(calc(H[1], H[0], H[2]), calc(H[1], H[2], H[0]))
b = min(calc(H[0], H[2], H[1]), calc(H[2], H[0], H[1]))
ans = min(a, b)
print(-1 if ans == INF else ans)
0