๋ฌธ์
https://www.acmicpc.net/problem/2477
ํ์ด
# ๋ฐฑ์ค 2477๋ฒ ๋ฌธ์ - ์ฐธ์ธ๋ฐญ
melon = int(input()) # ์ฐธ์ธ ๊ฐ์ K
values = [input().split() for _ in range(6)] # ๋๋จธ์ง 2~7 line์ 6 ์ค์ ์
๋ ฅ ๋ฐ๋๋ค.
directions = [int(v[0]) for v in values] # ๋ฐฉํฅ์ ๋ฝ์๋ด์ ์ ์ฅํ๋ค.
lengths = [int(v[1]) for v in values] # ๊ธธ์ด๋ฅผ ๋ฝ์๋ด์ ์ ์ฅํ๋ค.
max_lengths, box_lengths = [], [] # ํฐ ๋ฐ์ค์ ๊ธธ์ด, ์์ ๋ฐ์ค์ ๊ธธ์ด๋ฅผ ๋ด์ ๋ฐฐ์ด
for i in range(1, 5):
if directions.count(i) == 1: # direction์ด ํ๋ฒ๋ง ์กด์ฌํ๋ค == ํฐ ๋ฐ์ค์ ๋ณ
max_lengths.append(lengths[directions.index(i)]) # ํฐ๋ฐ์ค์ ๋ณ ๊ธธ์ด ์ ์ฅ
temp = directions.index(i) + 3 # ํฐ ๋ฐ์ค + 3 == ์์ ๋ฐ์ค์ ๋ณ
if temp >= 6:
temp -= 6 # cycle์ ์ํด 6 ์ด์์ผ ๊ฒฝ์ฐ -6
box_lengths.append(lengths[temp])
area = max_lengths[0] * max_lengths[1] - box_lengths[0] * box_lengths[1]
print(melon * area)
'๐๏ธ Algorithm > ๐ฉ ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ฉ [๋ฐฑ์ค] [Python] [Gold5] 14719๋ฒ_๋น๋ฌผ (0) | 2023.06.21 |
---|---|
๐ฉ [๋ฐฑ์ค] [Python] [Gold3] 14890๋ฒ_๊ฒฝ์ฌ๋ก (0) | 2023.06.19 |
๐ฉ [๋ฐฑ์ค] [Python] [Silver2] 3085๋ฒ_์ฌํ ๊ฒ์ (0) | 2023.06.14 |
๐ฉ [๋ฐฑ์ค] [Python] [Silver3] 15903๋ฒ_์นด๋ ํฉ์ฒด ๋์ด (0) | 2023.05.29 |
๐ฉ [๋ฐฑ์ค] [Python] [Silver3] 2346๋ฒ_ํ์ ํฐ๋จ๋ฆฌ๊ธฐ (0) | 2023.05.29 |