진짜 오랜만에 알고리즘 푸는데..
플레 가야지(?)
1931 풀이
해답
def solution(N, M:list):
if len(M) == 1:
return 1
M.sort(key=lambda x : (x[0], x[1]))
stack = [M[0]]
for m in M[1:]:
before = stack.pop()
now = m
if before[1] <= now[0]:
stack.append(before)
stack.append(now)
continue
if before[1] > now[1]:
stack.append(now)
continue
stack.append(before)
return len(stack)
N = int(input())
M = []
for _ in range(N):
M.append(list(map(int, input().split())))
print(solution(N, M))
2
1 2
1 1
2