結果

問題 No.281 門松と魔法(1)
ユーザー しらっ亭しらっ亭
提出日時 2015-09-23 22:45:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,006 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 16,768 KB
最終ジャッジ日時 2024-04-24 11:53:23
合計ジャッジ時間 3,274 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

def solve():
    d = int(input())

    h1 = int(input())
    h2 = int(input())
    h3 = int(input())

    ans = 0
    states = set()
    states.add((h1, h2, h3))

    while states:
        new = set()
        for h in states:
            zs = h.count(0)
            if zs >= 2:
                print(-1)
                return

            ma = max(h)
            mi = min(h)
            mic = h.count(mi)

            if h[0] != h[1] and h[0] != h[2] and h[1] != h[2] and (h[1] == ma or h[1] == mi):
                print(ans)
                return

            if h[1] > 0 and not (h[1] == mi and mic == 1) and h[1] != ma:
                new.add((h[0], max(0, h[1] - d), h[2]))
            if h[0] > 0 and not (h[0] == mi and mic == 1):
                new.add((max(0, h[0] - d), h[1], h[2]))
            if h[2] > 0 and not (h[1] == mi and mic == 1):
                new.add((h[0], h[1], max(0, h[2] - d)))
        states = new
        ans += 1

    print(-1)


if __name__ == '__main__':
    solve()
0