๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿงฉps/๐Ÿ”ฅNormal

[๋ฐฑ์ค€ 2096๋ฒˆ] ๋‚ด๋ ค๊ฐ€๊ธฐ

by goguma.dev 2024. 10. 13.

๐Ÿ“–๋ฌธ์ œ:

  

๐Ÿ“™ํ’€์ด:

ํ•œ ๋ผ์ธ์—๋Š” ์ˆซ์ž๊ฐ€ 3๊ฐœ๋กœ ์ผ์ •ํ•˜๋ฏ€๋กœ, 3*2 ์ด์ฐจ์› ๋ฆฌ์ŠคํŠธ๋ฅผ ์ด์šฉํ•˜์—ฌ,

๋ฐ˜๋ณต๋ฌธ์„ ํ•œ ๋ฒˆ๋งŒ ์‚ฌ์šฉํ•˜์—ฌ ์ตœ์†Œ๊ฐ’๊ณผ ์ตœ๋Œ€๊ฐ’์„ ๊ณ„์† ๊ฐฑ์‹ ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ด์šฉํ•จ.

 

โœ๏ธ์ฝ”๋“œ:

'''
https://www.acmicpc.net/problem/2096
๋ฌธ์ œ: ๋‚ด๋ ค๊ฐ€๊ธฐ
๋‚œ์ด๋„: ๊ณจ๋“œ5
'''
import sys

line = int(sys.stdin.readline())
first, second, third = map(int, sys.stdin.readline().split())
last = [[first, first], [second, second], [third, third]] # ์ ค ์œ„์— ๊ฐ’๋“ค์„ ๋จผ์ € ์„ธํŒ…

for _ in range(line-1):
    a, b, c = map(int, sys.stdin.readline().split())
    temp1 = a + min(last[0][0], last[1][0])
    temp2 = a + max(last[0][1], last[1][1])
    temp3 = b + min(last[0][0], last[1][0], last[2][0])
    temp4 = b + max(last[0][1], last[1][1], last[2][1])
    temp5 = c + min(last[1][0], last[2][0])
    temp6 = c + max(last[1][1], last[2][1])
    last = [[temp1, temp2], [temp3, temp4], [temp5, temp6]]

print(max(last[0][1], last[1][1], last[2][1]), min(last[0][0], last[1][0], last[2][0]))

 

๐Ÿ”—๋งํฌ:

https://www.acmicpc.net/problem/2096