結果
問題 | No.281 門松と魔法(1) |
ユーザー |
![]() |
提出日時 | 2017-07-26 08:21:12 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 870 bytes |
コンパイル時間 | 177 ms |
コンパイル使用メモリ | 82,256 KB |
実行使用メモリ | 67,264 KB |
最終ジャッジ日時 | 2024-10-09 17:34:40 |
合計ジャッジ時間 | 4,222 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 37 WA * 11 RE * 9 |
ソースコード
d = int(input())H1 = int(input())H2 = int(input())H3 = int(input())impossible = 9999999999ans = impossibledef A(a, b, c):result = 0if a == c:if a <= d:return impossibleelse:a = max(0, a - d)result += 1m = min(a, c)if b >= m:sa = b - mbb = sa // d + 1result += bbreturn resultdef B(a, b, c):result = 0if b == 0:return impossibleif a >= b:sa = a - baa = sa // d + 1result += aaa = max(0, a - aa * d)if c >= b:sa = c - bcc = sa // d + 1result += ccc = max(0, c - cc * d)if a == c:if a == 0:return impossibleresult +=1return resultans = min(A(H1,H2,H3),B(H1,H2,H3))print(-1 if ans == impossible else ans)