結果
問題 | No.281 門松と魔法(1) |
ユーザー | yuppe19 😺 |
提出日時 | 2016-07-17 06:11:57 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 34 ms / 1,000 ms |
コード長 | 1,026 bytes |
コンパイル時間 | 98 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-11-06 20:46:57 |
合計ジャッジ時間 | 3,270 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
10,752 KB |
testcase_01 | AC | 34 ms
10,752 KB |
testcase_02 | AC | 31 ms
10,880 KB |
testcase_03 | AC | 30 ms
10,752 KB |
testcase_04 | AC | 30 ms
10,752 KB |
testcase_05 | AC | 31 ms
10,880 KB |
testcase_06 | AC | 31 ms
10,752 KB |
testcase_07 | AC | 31 ms
10,752 KB |
testcase_08 | AC | 29 ms
10,752 KB |
testcase_09 | AC | 30 ms
10,752 KB |
testcase_10 | AC | 30 ms
10,752 KB |
testcase_11 | AC | 30 ms
10,752 KB |
testcase_12 | AC | 30 ms
10,880 KB |
testcase_13 | AC | 31 ms
10,752 KB |
testcase_14 | AC | 30 ms
10,752 KB |
testcase_15 | AC | 31 ms
10,752 KB |
testcase_16 | AC | 31 ms
10,752 KB |
testcase_17 | AC | 30 ms
10,752 KB |
testcase_18 | AC | 31 ms
10,752 KB |
testcase_19 | AC | 30 ms
10,752 KB |
testcase_20 | AC | 31 ms
10,752 KB |
testcase_21 | AC | 30 ms
10,880 KB |
testcase_22 | AC | 31 ms
10,752 KB |
testcase_23 | AC | 31 ms
10,752 KB |
testcase_24 | AC | 30 ms
10,752 KB |
testcase_25 | AC | 31 ms
10,880 KB |
testcase_26 | AC | 31 ms
10,752 KB |
testcase_27 | AC | 30 ms
10,752 KB |
testcase_28 | AC | 30 ms
10,752 KB |
testcase_29 | AC | 29 ms
10,752 KB |
testcase_30 | AC | 30 ms
10,752 KB |
testcase_31 | AC | 30 ms
10,752 KB |
testcase_32 | AC | 30 ms
10,752 KB |
testcase_33 | AC | 30 ms
10,752 KB |
testcase_34 | AC | 30 ms
10,752 KB |
testcase_35 | AC | 30 ms
10,752 KB |
testcase_36 | AC | 31 ms
10,752 KB |
testcase_37 | AC | 30 ms
10,752 KB |
testcase_38 | AC | 30 ms
10,752 KB |
testcase_39 | AC | 31 ms
10,880 KB |
testcase_40 | AC | 30 ms
10,880 KB |
testcase_41 | AC | 31 ms
10,752 KB |
testcase_42 | AC | 30 ms
10,752 KB |
testcase_43 | AC | 30 ms
10,880 KB |
testcase_44 | AC | 30 ms
10,752 KB |
testcase_45 | AC | 30 ms
10,880 KB |
testcase_46 | AC | 30 ms
10,752 KB |
testcase_47 | AC | 32 ms
10,752 KB |
testcase_48 | AC | 30 ms
10,752 KB |
testcase_49 | AC | 31 ms
10,752 KB |
testcase_50 | AC | 30 ms
10,752 KB |
testcase_51 | AC | 31 ms
10,752 KB |
testcase_52 | AC | 30 ms
10,752 KB |
testcase_53 | AC | 31 ms
10,752 KB |
testcase_54 | AC | 31 ms
10,752 KB |
testcase_55 | AC | 30 ms
10,752 KB |
testcase_56 | AC | 31 ms
10,880 KB |
ソースコード
#!/usr/bin/python3 inf = float('inf') def bye(s): print(s) exit(0) def ok(x, y, z): ok1 = x > y and y < z ok2 = x < y and y > z return x!=z and (ok1 or ok2) def count(my, your, d): if your==0: return inf if my < your: return 0 return (my - your + d) // d def cut(my, d, times): return max(0, my-d*times) d = int(input()) h1 = int(input()) h2 = int(input()) h3 = int(input()) assert 0 <= d <= 10**9 assert 0 <= h1 <= 10**9 assert 0 <= h2 <= 10**9 assert 0 <= h3 <= 10**9 if ok(h1, h2, h3): bye('0') if d==0: bye('-1') r1 = 0 x, y, z = h1, h2, h3 if x==z: x = cut(x, d, 1) r1 += 1 p = count(x, y, d) r1 += p x = cut(x, d, p) q = count(z, y, d) r1 += q z = cut(z, d, q) if not ok(x, y, z): r1 = inf r2 = 0 x, y, z = h1, h2, h3 if x==z: x = cut(x, d, 1) r2 += 1 p = count(y, x, d) r2 += p y = cut(y, d, p) q = count(y, z, d) r2 += q y = cut(y, d, q) if not ok(x, y, z): r2 = inf res = min(r1, r2) if res >= inf: res = -1 print(res)