Skip to content

Commit

Permalink
Merge pull request #267 from AlgoLeadMe/40-H0ngJu
Browse files Browse the repository at this point in the history
40-H0ngJu
  • Loading branch information
H0ngJu authored Feb 3, 2025
2 parents 79f1ee3 + 5cff202 commit e303da0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
=======
23 changes: 23 additions & 0 deletions H0ngJu/그리디/흙길 보수하기.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit e303da0

Please sign in to comment.