File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments