結果
問題 |
No.281 門松と魔法(1)
|
ユーザー |
|
提出日時 | 2015-09-18 22:52:45 |
言語 | Python2 (2.7.18) |
結果 |
WA
|
実行時間 | - |
コード長 | 890 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 7,040 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-06 18:50:49 |
合計ジャッジ時間 | 2,312 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 56 WA * 1 |
ソースコード
d = int(raw_input()) _H1, _H2, _H3 = int(raw_input()), int(raw_input()), int(raw_input()) if d == 0: if _H1 != _H3 and (_H1 < _H2 > _H3 or _H1 > _H2 < _H3): print 0 else: print -1 exit() ans = -1 a1 = a2 = 0 H1, H2, H3 = _H1, _H2, _H3 if H1 > H2: c = (H1 - H2 + d) / d H1 = max(0, H1 - d * c) a1 += c if H3 > H2: c = (H3 - H2 + d) / d H3 = max(0, H3 - d * c) a1 += c if H1 == H3: H1 = max(0, H1 - d) a1 += 1 if H1 != H3 and H1 < H2 > H3: ans = a1 H1, H2, H3 = _H1, _H2, _H3 if H1 < H2: c = (H2 - H1 + d) / d H2 = max(0, H2 - d * c) a2 += c if H3 < H2: c = (H2 - H3 + d) / d H2 = max(0, H2- d * c) a2 += c if H1 == H3: H1 = max(0, H1 - d) a2 += 1 if H1 == H2: H2 = max(0, H2 - d) a2 += 1 if H1 != H3 and H1 > H2 < H3: if ans == -1: ans = a2 else: ans = min(ans, a2) print ans