結果
問題 | No.281 門松と魔法(1) |
ユーザー | pekempey |
提出日時 | 2015-11-27 00:27:11 |
言語 | PyPy2 (7.3.15) |
結果 |
AC
|
実行時間 | 94 ms / 1,000 ms |
コード長 | 857 bytes |
コンパイル時間 | 1,689 ms |
コンパイル使用メモリ | 76,712 KB |
実行使用メモリ | 75,776 KB |
最終ジャッジ日時 | 2024-11-06 20:43:36 |
合計ジャッジ時間 | 8,160 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 91 ms
75,260 KB |
testcase_01 | AC | 91 ms
75,520 KB |
testcase_02 | AC | 91 ms
75,136 KB |
testcase_03 | AC | 91 ms
75,556 KB |
testcase_04 | AC | 82 ms
75,520 KB |
testcase_05 | AC | 79 ms
75,264 KB |
testcase_06 | AC | 76 ms
75,520 KB |
testcase_07 | AC | 78 ms
75,136 KB |
testcase_08 | AC | 78 ms
75,520 KB |
testcase_09 | AC | 77 ms
75,264 KB |
testcase_10 | AC | 77 ms
75,540 KB |
testcase_11 | AC | 81 ms
75,292 KB |
testcase_12 | AC | 78 ms
75,508 KB |
testcase_13 | AC | 77 ms
75,264 KB |
testcase_14 | AC | 76 ms
75,520 KB |
testcase_15 | AC | 76 ms
75,648 KB |
testcase_16 | AC | 75 ms
75,520 KB |
testcase_17 | AC | 78 ms
75,136 KB |
testcase_18 | AC | 81 ms
75,776 KB |
testcase_19 | AC | 77 ms
75,320 KB |
testcase_20 | AC | 77 ms
75,264 KB |
testcase_21 | AC | 75 ms
75,768 KB |
testcase_22 | AC | 77 ms
75,548 KB |
testcase_23 | AC | 81 ms
75,520 KB |
testcase_24 | AC | 78 ms
75,560 KB |
testcase_25 | AC | 78 ms
75,520 KB |
testcase_26 | AC | 77 ms
75,648 KB |
testcase_27 | AC | 78 ms
75,392 KB |
testcase_28 | AC | 78 ms
75,136 KB |
testcase_29 | AC | 79 ms
75,648 KB |
testcase_30 | AC | 77 ms
75,292 KB |
testcase_31 | AC | 79 ms
75,296 KB |
testcase_32 | AC | 81 ms
75,264 KB |
testcase_33 | AC | 80 ms
75,512 KB |
testcase_34 | AC | 79 ms
75,548 KB |
testcase_35 | AC | 78 ms
75,520 KB |
testcase_36 | AC | 91 ms
75,264 KB |
testcase_37 | AC | 92 ms
75,520 KB |
testcase_38 | AC | 94 ms
75,452 KB |
testcase_39 | AC | 77 ms
75,520 KB |
testcase_40 | AC | 78 ms
75,520 KB |
testcase_41 | AC | 83 ms
75,776 KB |
testcase_42 | AC | 85 ms
75,392 KB |
testcase_43 | AC | 83 ms
75,136 KB |
testcase_44 | AC | 83 ms
75,648 KB |
testcase_45 | AC | 80 ms
75,392 KB |
testcase_46 | AC | 80 ms
75,264 KB |
testcase_47 | AC | 83 ms
75,648 KB |
testcase_48 | AC | 78 ms
75,548 KB |
testcase_49 | AC | 83 ms
75,392 KB |
testcase_50 | AC | 78 ms
75,644 KB |
testcase_51 | AC | 78 ms
75,452 KB |
testcase_52 | AC | 77 ms
75,520 KB |
testcase_53 | AC | 76 ms
75,776 KB |
testcase_54 | AC | 75 ms
75,520 KB |
testcase_55 | AC | 77 ms
75,520 KB |
testcase_56 | AC | 76 ms
75,392 KB |
ソースコード
import sys INF = 10 ** 18 d, h1, h2, h3 = [input() for _ in xrange(4)] def is_kadomatsu(a, b, c): return a != c and (a < b and b > c or a > b and b < c) if is_kadomatsu(h1, h2, h3): print 0 sys.exit() if d == 0: print -1 sys.exit() f = lambda x: max(0, x - d) ans = 0 if h1 == h3: h1 = f(h1) ans += 1 if h1 == h3: print -1 sys.exit() # h1 < h3 and h3 > h2 ans1 = ans t1, t2, t3 = h1, h2, h3 k1 = max(0, (t1 - t2 + d) / d) k3 = max(0, (t3 - t2 + d) / d) t1 = max(0, t1 - k1 * d) t3 = max(0, t3 - k3 * d) ans1 = ans + k1 + k3 if t1 == t3: t1 = f(t1) ans1 += 1 if not is_kadomatsu(t1, t2, t3): ans1 = INF # h1 > h3 and h3 < h2 t1, t2, t3 = h1, h2, h3 k2 = max(0, (t2 - min(t1, t3) + d) / d) ans2 = ans + k2 t2 = max(0, t2 - k2 * d) if not is_kadomatsu(t1, t2, t3): ans2 = INF ans = min(ans1, ans2) if ans == INF: ans = -1 print ans