import sys input = sys.stdin.readline N = int(input()) M = int(input()) S = [0]*N E = [0]*N for _ in range(M): x, y = map(lambda x : x-1 ,list(map(int,input().split()))) S[x] += 1 E[y] += -1 ind = 0 result = 0 big_cnt = 0 while ind<N: if big_cnt: big_cnt += S[ind] + E[ind] if big_cnt == 0: result += 1 ind += 1 else: if S[ind] == 0: result += 1 else: big_cnt += S[ind] ind += 1 print(result)
'알고리즘 > 백준_복기_미완료' 카테고리의 다른 글
[BOJ/백준] 14601 샤워실 바닥 깔기(Large) (0) | 2021.05.05 |
---|---|
[BOJ/백준] 1717 집합의 표현 (0) | 2021.05.05 |
[BOJ/백준] 14570 나무 위의 구슬 (0) | 2021.05.05 |
[BOJ/백준] 14476 최대공약수 하나 빼기 (0) | 2021.05.05 |
[BOJ/백준] 13974 파일 합치기 2 (0) | 2021.05.05 |