結果
問題 | No.281 門松と魔法(1) |
ユーザー |
![]() |
提出日時 | 2020-12-17 21:06:50 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 944 bytes |
コンパイル時間 | 292 ms |
コンパイル使用メモリ | 82,104 KB |
実行使用メモリ | 67,112 KB |
最終ジャッジ日時 | 2024-09-21 08:16:13 |
合計ジャッジ時間 | 4,177 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 40 WA * 12 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 == H2: if H1 > 0: ans = min(ans,b+1) else: ans = min(ans,b) print(ans if ans != inf else -1)