-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1911.py
More file actions
33 lines (33 loc) · 789 Bytes
/
1911.py
File metadata and controls
33 lines (33 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sys
sys.setrecursionlimit(1000000)
N,L = map(int,sys.stdin.readline().split())
lake = []
for _ in range(N):
lake.append(list(map(int, sys.stdin.readline().split())))
lake.sort()
cnt = 0
for pool in range(len(lake)):
l = lake[pool][1]-lake[pool][0]
if pool == len(lake)-1:
cnt += (l-1)//L +1
break
if (l) % L:
tmp = L - ((l)% L)
now_corver = lake[pool][1] + tmp
if lake[pool+1][0] <=now_corver :
lake[pool+1][0] = now_corver
cnt += (l)//L +1
else :
cnt += (l)//L
print(cnt)
#시간초과
# for start, end in lake:
# if start > end:
# continue
# if now > start:
# start = now
# while start < end:
# start += L
# cnt += 1
# now = start
# print(cnt)