結果

問題 No.281 門松と魔法(1)
ユーザー mbanmban
提出日時 2017-07-26 08:21:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 870 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 66,744 KB
最終ジャッジ日時 2024-04-17 23:46:59
合計ジャッジ時間 4,031 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

d = int(input())
H1 = int(input())
H2 = int(input())
H3 = int(input())

impossible = 9999999999

ans = impossible


def A(a, b, c):
    result = 0
    if a == c:
        if a <= d:
            return impossible
        else:
            a = max(0, a - d)
            result += 1
    m = min(a, c)

    if b >= m:
        sa = b - m
        bb = sa // d + 1
        result += bb
    return result


def B(a, b, c):
    result = 0
    if b == 0:
        return impossible
    if a >= b:
        sa = a - b
        aa = sa // d + 1
        result += aa
        a = max(0, a - aa * d)
    if c >= b:
        sa = c - b
        cc = sa // d + 1
        result += cc
        c = max(0, c - cc * d)
    if a == c:
        if a == 0:
            return impossible
        result +=1
    return  result

ans = min(A(H1,H2,H3),B(H1,H2,H3))

print(-1 if ans == impossible else ans)
0