結果
問題 |
No.281 門松と魔法(1)
|
ユーザー |
![]() |
提出日時 | 2020-12-17 21:10:31 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 944 bytes |
コンパイル時間 | 233 ms |
コンパイル使用メモリ | 82,268 KB |
実行使用メモリ | 66,872 KB |
最終ジャッジ日時 | 2024-09-21 08:16:49 |
合計ジャッジ時間 | 3,872 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 RE * 5 |
ソースコード
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) d = I() H1,H2,H3 = I(),I(),I() inf = 10**18 ans = inf m = min(H1,H3) a = 0 if H1 == H3: m -= d a += 1 if H2 < m: ans = min(ans,a) elif m > 0: a += (H2-m)//d+1 ans = min(ans,a) b = 0 if H2 > 0: b += max(0,(H1-H2)//d+1) b += max(0,(H3-H2)//d+1) H1 = max(0,H1-d*max(0,(H1-H2)//d+1)) H3 = max(0,H3-d*max(0,(H3-H2)//d+1)) if H1 == H3: if H1 > 0: ans = min(ans,b+1) else: ans = min(ans,b) print(ans if ans != inf else -1)