ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 2096 |
문제명 | 내려가기 |
레벨 | 골드 4 |
분류 |
DP |
시간복잡도 | O(n) |
인풋사이즈 | n<=100,000 |
사용한 언어 | Python |
제출기록 | 29200KB / 300ms |
최고기록 | 292ms |
해결날짜 | 2021/08/12 |
"""Solution code for "BOJ 2096. 내려가기".
- Problem link: https://www.acmicpc.net/problem/2096
- Solution link: http://www.teferi.net/ps/problems/boj/2096
Tags: [DP]
"""
import sys
def main():
N = int(sys.stdin.readline())
min_l = min_m = min_r = max_l = max_m = max_r = 0
for _ in range(N):
l, m, r = [int(x) for x in sys.stdin.readline().split()]
min_l, min_m, min_r = (min(min_l, min_m) + l,
min(min_l, min_m, min_r) + m,
min(min_m, min_r) + r)
max_l, max_m, max_r = (max(max_l, max_m) + l,
max(max_l, max_m, max_r) + m,
max(max_m, max_r) + r)
print(max(max_l, max_m, max_r), min(min_l, min_m, min_r))
if __name__ == '__main__':
main()