結果

問題 No.281 門松と魔法(1)
ユーザー rlangevinrlangevin
提出日時 2023-07-22 18:58:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 1,000 ms
コード長 684 bytes
コンパイル時間 1,361 ms
コンパイル使用メモリ 81,356 KB
実行使用メモリ 53,404 KB
最終ジャッジ日時 2023-10-24 01:28:48
合計ジャッジ時間 6,223 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,404 KB
testcase_01 AC 39 ms
53,404 KB
testcase_02 AC 39 ms
53,404 KB
testcase_03 AC 39 ms
53,404 KB
testcase_04 AC 39 ms
53,404 KB
testcase_05 AC 38 ms
53,404 KB
testcase_06 AC 38 ms
53,404 KB
testcase_07 AC 38 ms
53,404 KB
testcase_08 AC 38 ms
53,404 KB
testcase_09 AC 38 ms
53,404 KB
testcase_10 AC 38 ms
53,404 KB
testcase_11 AC 38 ms
53,404 KB
testcase_12 AC 38 ms
53,404 KB
testcase_13 AC 39 ms
53,404 KB
testcase_14 AC 38 ms
53,404 KB
testcase_15 AC 38 ms
53,404 KB
testcase_16 AC 39 ms
53,404 KB
testcase_17 AC 38 ms
53,404 KB
testcase_18 AC 38 ms
53,404 KB
testcase_19 AC 39 ms
53,404 KB
testcase_20 AC 38 ms
53,404 KB
testcase_21 AC 38 ms
53,404 KB
testcase_22 AC 39 ms
53,404 KB
testcase_23 AC 38 ms
53,404 KB
testcase_24 AC 39 ms
53,404 KB
testcase_25 AC 38 ms
53,404 KB
testcase_26 AC 39 ms
53,404 KB
testcase_27 AC 38 ms
53,404 KB
testcase_28 AC 38 ms
53,404 KB
testcase_29 AC 39 ms
53,404 KB
testcase_30 AC 38 ms
53,404 KB
testcase_31 AC 39 ms
53,404 KB
testcase_32 AC 39 ms
53,404 KB
testcase_33 AC 38 ms
53,404 KB
testcase_34 AC 38 ms
53,404 KB
testcase_35 AC 38 ms
53,404 KB
testcase_36 AC 39 ms
53,404 KB
testcase_37 AC 39 ms
53,404 KB
testcase_38 AC 39 ms
53,404 KB
testcase_39 AC 39 ms
53,404 KB
testcase_40 AC 39 ms
53,404 KB
testcase_41 AC 39 ms
53,404 KB
testcase_42 AC 39 ms
53,404 KB
testcase_43 AC 39 ms
53,404 KB
testcase_44 AC 39 ms
53,404 KB
testcase_45 AC 39 ms
53,404 KB
testcase_46 AC 39 ms
53,404 KB
testcase_47 AC 39 ms
53,404 KB
testcase_48 AC 39 ms
53,404 KB
testcase_49 AC 40 ms
53,404 KB
testcase_50 AC 39 ms
53,404 KB
testcase_51 AC 40 ms
53,404 KB
testcase_52 AC 39 ms
53,404 KB
testcase_53 AC 39 ms
53,404 KB
testcase_54 AC 39 ms
53,404 KB
testcase_55 AC 40 ms
53,404 KB
testcase_56 AC 39 ms
53,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

d = int(input())
inf = 10 ** 18
H = [0] * 3
for i in range(3):
    H[i] = int(input())
    
def check(A, d):
    if d == 0:
        if A[0] > A[1] > A[2]:
            return 0
        else:
            return inf
        
    cnt = 0
    if A[1] >= A[0]:
        cnt = (A[1] - A[0] + 1 + d - 1)//d
        A[1] -= cnt * d
    if A[1] <= 0:
        return inf
    
    if A[2] >= A[1]:
        cnt += (A[2] - A[1] + 1 + d - 1)//d
    
    return cnt
    
ans = inf
ans = min(ans, check([H[1], H[0], H[2]], d))
ans = min(ans, check([H[1], H[2], H[0]], d))
ans = min(ans, check([H[2], H[0], H[1]], d))
ans = min(ans, check([H[0], H[2], H[1]], d))

print(ans) if ans != inf else print(-1)
0