Skip to content

Commit 4630a6a

Browse files
committed
[#5]16937 두 스티커
1 parent fd02171 commit 4630a6a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
h, w = map(int, input().split())
2+
n = int(input())
3+
stk = [list(map(int, input().split())) for _ in range(n)]
4+
5+
res = 0
6+
for i in range(n):
7+
for j in range(i+1, n):
8+
r1, c1 = stk[i]
9+
r2, c2 = stk[j]
10+
11+
# 두 스티커 모두 회전하지 않는 경우(세로로 나란히 배치/가로로 나란히 배치)
12+
if (r1 + r2 <= h and max(c1, c2) <= w) or (c1 + c2 <= w and max(r1, r2) <= h):
13+
res = max(res, r1*c1 + r2*c2)
14+
# 첫 번째 스티커만 회전하는 경우
15+
if (c1 + r2 <= h and max(r1, c2) <= w) or (r1 + c2 <= w and max(c1, r2) <= h):
16+
res = max(res, r1*c1 + r2*c2)
17+
# 두 번째 스티커만 회전하는 경우
18+
if (r1 + c2 <= h and max(c1, r2) <= w) or (c1 + r2 <= w and max(r1, c2) <= h):
19+
res = max(res, r1*c1 + r2*c2)
20+
# 두 스티커 모두 회전하는 경우
21+
if (c1 + c2 <= h and max(r1, r2) <= w) or (r1 + r2 <= w and max(c1, c2) <= h):
22+
res = max(res, r1*c1 + r2*c2)
23+
24+
print(res)

0 commit comments

Comments
 (0)