From 79e925f098a9a522cad4b8010bc604a7191e540b Mon Sep 17 00:00:00 2001 From: H0ngJu Date: Tue, 28 Jan 2025 07:13:03 +0900 Subject: [PATCH] 2025-01-28 --- H0ngJu/README.md | 2 ++ ...64\354\210\230\355\225\230\352\270\260.py" | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 "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" diff --git a/H0ngJu/README.md b/H0ngJu/README.md index 75c8f0c..9c61b63 100644 --- a/H0ngJu/README.md +++ b/H0ngJu/README.md @@ -39,3 +39,5 @@ | 35차시 | 2024.11.23 | DP | [전깃줄](https://www.acmicpc.net/problem/2565) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/258 | | 36차시 | 2024.12.02 | 수학 | [머리 톡톡](https://www.acmicpc.net/problem/1241) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/260 | | 36차시 | 2024.12.31 | 그리디 | [회의실 배정](https://www.acmicpc.net/problem/1931) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/261 | + +| 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