From 7122c4e7897c6fcc89339536b160f7e6b49acccb Mon Sep 17 00:00:00 2001 From: H0ngJu Date: Sat, 5 Oct 2024 22:32:02 +0900 Subject: [PATCH] 2024-10-05 --- H0ngJu/README.md | 17 ++++++------ .../\354\204\240 \352\270\213\352\270\260.py" | 26 +++++++++++++++++++ 2 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 "H0ngJu/\354\240\225\353\240\254/\354\204\240 \352\270\213\352\270\260.py" diff --git a/H0ngJu/README.md b/H0ngJu/README.md index 35c4a92..557bc31 100644 --- a/H0ngJu/README.md +++ b/H0ngJu/README.md @@ -24,11 +24,12 @@ | 20차시 | 2024.06.03 | 백트래킹 | [스타트와 링크](https://www.acmicpc.net/problem/14889) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/206 | | 21차시 | 2024.06.07 | 그리디 | [행복 유치원](https://www.acmicpc.net/problem/13164) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/208 | | 22차시 | 2024.08.06 | 해시 | [의상](https://school.programmers.co.kr/learn/courses/30/lessons/42578) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/224 | -| 23차시 | 2024.08.10 | 해시 | [베스트앨범](https://school.programmers.co.kr/learn/courses/30/lessons/42579) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/227 | -| 24차시 | 2024.08.17 | BFS | [아기상어](https://www.acmicpc.net/problem/16236) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/233 | -| 25차시 | 2024.08.17 | DFS | [친구비](https://www.acmicpc.net/problem/16562) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/234 | -| 26차시 | 2024.08.24 | 그리디 | [신입사원](https://www.acmicpc.net/problem/1946) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/237 | -| 27차시 | 2024.08.27 | DFS | [트리의 지름](https://www.acmicpc.net/problem/1967) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/240 | -| 28차시 | 2024.09.04 | 벨만포드 | [타임머신](https://www.acmicpc.net/problem/11657) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/244 | -| 29차시 | 2024.09.06 | 구현 | [톱니바퀴](https://www.acmicpc.net/problem/14891) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/245 | ---- \ No newline at end of file +| 23차시 | 2024.08.10 | 해시 | [베스트앨범](https://school.programmers.co.kr/learn/courses/30/lessons/42579) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/227 | +| 24차시 | 2024.08.17 | BFS | [아기상어](https://www.acmicpc.net/problem/16236) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/233 | +| 25차시 | 2024.08.17 | DFS | [친구비](https://www.acmicpc.net/problem/16562) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/234 | +| 26차시 | 2024.08.24 | 그리디 | [신입사원](https://www.acmicpc.net/problem/1946) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/237 | +| 27차시 | 2024.08.27 | DFS | [트리의 지름](https://www.acmicpc.net/problem/1967) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/240 | +| 28차시 | 2024.09.04 | 벨만포드 | [타임머신](https://www.acmicpc.net/problem/11657) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/244 | +| 29차시 | 2024.09.06 | 구현 | [톱니바퀴](https://www.acmicpc.net/problem/14891) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/245 | + +## | 31차시 | 2024.10.05 | 정렬 | [선 긋기](https://www.acmicpc.net/problem/2170) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/249 | diff --git "a/H0ngJu/\354\240\225\353\240\254/\354\204\240 \352\270\213\352\270\260.py" "b/H0ngJu/\354\240\225\353\240\254/\354\204\240 \352\270\213\352\270\260.py" new file mode 100644 index 0000000..ccfeede --- /dev/null +++ "b/H0ngJu/\354\240\225\353\240\254/\354\204\240 \352\270\213\352\270\260.py" @@ -0,0 +1,26 @@ +import sys + +def input() : return sys.stdin.readline().rstrip() + +length = 0 +start = 0 +end = 0 + +N = int(input()) +lines = [tuple(map(int, input().split())) for _ in range(N)] +lines.sort() + +for i in range(N): + x, y = lines[i] + if i == 0: + start = x + end = y + else: + if x<= end: + end = max(end, y) + else: + length += abs(end-start) # 이전 선분은 필요 없음 + start = x + end = y + +print(abs(end-start + length)) \ No newline at end of file