https://www.acmicpc.net/problem/14464
import sys
import heapq
C, N = map(int, sys.stdin.readline().rstrip().split())
chickens = []
for _ in range(C):
heapq.heappush(chickens, int(sys.stdin.readline()))
cows = []
for _ in range(N):
s, e = map(int, sys.stdin.readline().rstrip().split())
heapq.heappush(cows, (e, s))
ans = 0
while chickens:
chicken = heapq.heappop(chickens)
while cows and cows[0][1] <= chicken:
cow = heapq.heappop(cows)
if chicken <= cow[0]:
ans += 1
break
print(ans)
# 2 2
# 2
# 4
# 1 5
# 2 3
# output: 2
# 5 4
# 2
# 6
# 7
# 8
# 9
# 0 3
# 2 5
# 4 9
# 8 13
# output:
# 3
# 1 2
# 5
# 1 1
# 5 5
#
# output:
# 1
틀렸다는데 도대체 왜 틀린지 모르겠다..
반례를 찾을 수가 없다.. 토할 것 같다......ㄷ ㄷ ㄷ