Created
February 11, 2026 02:24
-
-
Save maehrm/ba963bd81e52cef0a1404df164e9e1c1 to your computer and use it in GitHub Desktop.
E - Placing Rectangles https://atcoder.jp/contests/abc223/tasks/abc223_e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from itertools import permutations | |
| def need_w(s, h): | |
| return (s + h - 1) // h | |
| def need_h(s, w): | |
| return (s + w - 1) // w | |
| def check(): | |
| for a, b, c in permutations([A, B, C]): | |
| # 横に3つ | |
| if need_w(a, Y) + need_w(b, Y) + need_w(c, Y) <= X: | |
| return True | |
| # 縦に3つ | |
| if need_h(a, X) + need_h(b, X) + need_h(c, X) <= Y: | |
| return True | |
| # 上1個、下に横2個 | |
| hA = need_h(a, X) | |
| if hA < Y: | |
| rest = Y - hA | |
| # 残りの部分に2つ横に並べられるか? | |
| if need_w(b, rest) + need_w(c, rest) <= X: | |
| return True | |
| # 左1個、右に縦2個 | |
| wA = need_w(a, Y) | |
| if wA < X: | |
| rest = X - wA | |
| if need_h(b, rest) + need_h(c, rest) <= Y: | |
| return True | |
| return False | |
| X, Y, A, B, C = map(int, input().split()) | |
| print("Yes" if check() else "No") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment