結果
| 問題 |
No.281 門松と魔法(1)
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-07-26 08:26:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,216 bytes |
| コンパイル時間 | 199 ms |
| コンパイル使用メモリ | 82,564 KB |
| 実行使用メモリ | 67,004 KB |
| 最終ジャッジ日時 | 2024-10-09 17:34:44 |
| 合計ジャッジ時間 | 4,006 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 WA * 1 RE * 9 |
ソースコード
d = int(input())
H1 = int(input())
H2 = int(input())
H3 = int(input())
impossible = 9999999999
ans = impossible
def Kadomatsu(a,b,c):
if a == b or b == c or c == a:
return False
if a<=b and b <= c:
return False
if a>= b and b >= c:
return False
return True
def A(a, b, c):
result = 0
if a == c:
if a <= d:
return impossible
else:
a = max(0, a - d)
result += 1
m = min(a, c)
if b >= m:
sa = b - m
bb = sa // d + 1
b = max(0,b-bb*d)
result += bb
if Kadomatsu(a,b,c):
return result
else:
return impossible
def B(a, b, c):
result = 0
if b == 0:
return impossible
if a >= b:
sa = a - b
aa = sa // d + 1
result += aa
a = max(0, a - aa * d)
if c >= b:
sa = c - b
cc = sa // d + 1
result += cc
c = max(0, c - cc * d)
if a == c:
if a == 0:
return impossible
result +=1
if Kadomatsu(a,b,c):
return result
else:
return impossible
ans = min(A(H1,H2,H3),B(H1,H2,H3))
print(-1 if ans == impossible else ans)
mban