티스토리 뷰
문제 링크
문제 풀이
k = int(input())
width = []
height = []
total = []
for i in range(6):
dir, len = map(int, input().split())
if dir == 1 or dir ==2:
width.append(len)
total.append(len)
else:
height.append(len)
total.append(len)
maxHeightIndex = total.index(max(height))
maxWidthIndex = total.index(max(width))
small1 = abs(total[maxHeightIndex-1] - total[(maxHeightIndex-5 if maxHeightIndex == 5 else maxHeightIndex +1)])
small2 = abs(total[maxWidthIndex-1] - total[(maxWidthIndex-5 if maxWidthIndex == 5 else maxWidthIndex +1)])
print((max(height) * max(width) - small1 * small2) * k)
*key point: 큰 사각형에서 작은 사각형의 넓이를 뺀다는 아이디어로 쉽게 풀이할 수 있다. 가로 길이와 세로 길이의 최대값을 통해 큰 사각형의 넓이를 구하고, 각 최대길이 변의 양옆 변의 길이의 차가 작은 사각형의 한 변임을 이용한다.
'What I Learned > Algorithm Practice' 카테고리의 다른 글
[백준 - python] 1002번: 터렛 (0) | 2022.11.19 |
---|---|
[백준 - python] 3053번: 택시 기하학 (0) | 2022.11.18 |
[백준 - python] 4153번: 직각삼각형 (0) | 2022.11.16 |
[백준 - python] 3009번: 네 번째 점 (0) | 2022.11.15 |
[백준 - python] 1085번: 직사각형에서 탈출 (0) | 2022.11.14 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- til
- Wil
- SQL
- 항해 플러스
- Programmers
- 24723
- 25501
- 20920
- 5597
- 24060
- 13241
- Python
- 벡준
- 13909
- 2053
- 백준
- 2738
- 코육대
- 1269
- 26069
- programmer
- 2587
- 10807
- 항해+
- 24313
- 4134
- 2903
- 25192
- 17103
- MySQL
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함