Skip to content

Commit 507a9e1

Browse files
committed
[PGS] 단속 카메라 / Level 3 / 60분 / 힌트, 성공
1 parent 661079a commit 507a9e1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import heapq
2+
3+
def solution(routes):
4+
routes.sort(key=lambda x:x[0])
5+
6+
answer = 0
7+
h = [30001]
8+
for r in routes:
9+
earliestend = heapq.heappop(h)
10+
if r[0] > earliestend:
11+
answer += 1
12+
h.clear()
13+
else:
14+
heapq.heappush(h, earliestend)
15+
heapq.heappush(h, r[1])
16+
else:
17+
if len(h) != 0:
18+
answer += 1
19+
return answer

0 commit comments

Comments
 (0)