diff --git a/H0ngJu/README.md b/H0ngJu/README.md index 5d06ee8..57ae2b1 100644 --- a/H0ngJu/README.md +++ b/H0ngJu/README.md @@ -41,3 +41,5 @@ | 37차시 | 2024.12.31 | 그리디 | [회의실 배정](https://www.acmicpc.net/problem/1931) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/262 | | 38차시 | 2024.01.06 | 정렬 | [최소 회의실 개수](https://www.acmicpc.net/problem/19598) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/263 | | 39차시 | 2024.01.18 | 정렬 | [컬러볼](https://www.acmicpc.net/problem/10800) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/266 | +| 40차시 | 2025.01.28 | 그리디 | [흙길 보수하기](https://www.acmicpc.net/problem/1911) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/267 | +======= diff --git "a/H0ngJu/\352\267\270\353\246\254\353\224\224/\355\235\231\352\270\270 \353\263\264\354\210\230\355\225\230\352\270\260.py" "b/H0ngJu/\352\267\270\353\246\254\353\224\224/\355\235\231\352\270\270 \353\263\264\354\210\230\355\225\230\352\270\260.py" new file mode 100644 index 0000000..bd154cb --- /dev/null +++ "b/H0ngJu/\352\267\270\353\246\254\353\224\224/\355\235\231\352\270\270 \353\263\264\354\210\230\355\225\230\352\270\260.py" @@ -0,0 +1,23 @@ +import sys +import math + +def input(): return sys.stdin.readline().strip() +N, L = map(int, input().split()) +info = [list(map(int, input().split())) for _ in range(N)] +info.sort() + +prev_start = -1 +prev_end = -1 +cnt = 0 + +for start, end in info: + if prev_end < end: + if start <= prev_end: + prev_start = prev_end + 1 + else: + prev_start = start + need = math.ceil((end - prev_start) / L) + prev_end = need * L + prev_start - 1 + cnt += need + +print(cnt) \ No newline at end of file