Skip to content

Commit

Permalink
Merge pull request #249 from AlgoLeadMe/31-H0ngJu
Browse files Browse the repository at this point in the history
31-H0ngJu
  • Loading branch information
H0ngJu authored Oct 10, 2024
2 parents 7d102be + a2d6396 commit 5cc337f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
5 changes: 2 additions & 3 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
| 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 |
| 29์ฐจ์‹œ | 2024.09.06 | ๊ตฌํ˜„ |[ํ†ฑ๋‹ˆ๋ฐ”ํ€ด](https://www.acmicpc.net/problem/14891) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/245 |
| 30์ฐจ์‹œ | 2024.09.27 | ์ˆ˜ํ•™ | [Fly me to the Alpha Centauri](https://www.acmicpc.net/problem/1011) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/248 |

---
| 31์ฐจ์‹œ | 2024.10.05 | ์ •๋ ฌ | [์„  ๊ธ‹๊ธฐ](https://www.acmicpc.net/problem/2170) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/249 |
26 changes: 26 additions & 0 deletions H0ngJu/์ •๋ ฌ/์„  ๊ธ‹๊ธฐ.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 5cc337f

Please sign in to comment.