結果
| 問題 | No.281 門松と魔法(1) |
| コンテスト | |
| ユーザー |
tnoda_
|
| 提出日時 | 2015-10-02 15:52:28 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 728 bytes |
| 記録 | |
| コンパイル時間 | 232 ms |
| コンパイル使用メモリ | 77,576 KB |
| 最終ジャッジ日時 | 2025-12-03 17:13:15 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 52 WA * 1 RE * 4 |
ソースコード
d = input()
H = []
for i in range(3):
H.append(input())
def upward():
if H[1] == 0:
return None
x = [0, 0, 0]
y = list(H)
z = 0
for i in [0, 2]:
if H[i] >= H[1]:
x[i] = max((H[i] - H[1]) / d, -1) + 1
y[i] = max(0, H[i] - d * x[i])
if y[0] == y[2]:
y[0] -= d
z += 1
if y[0] < 0:
return None
return sum(x) + z
def downward():
z = 0
if H[0] == H[2]:
H[0] -= d
z += 1
if H[0] <= 0 or H[2] <= 0:
return None
y = min(H[0], H[2])
return max((H[1] - y) / d, -1) + 1 + z
ans = [x for x in [upward(), downward()] if x is not None]
if len(ans) == 0:
print(-1)
else:
print(min(ans))
tnoda_