
Greedy
- 중요한 것은 각 숫자별로 '최저값'을 어떻게 설정하는가이다.
- 당연히 1등부터 점수가 있으니까 1등이 제일 최저값이지만, 1등이라고 해서 모두 [1, 1] 형식인 것은 아니다
- 그러므로 한 분야의 1등을 정한 뒤 나머지 부분의 최저값을 계속 갱신해 나가는 것이 이번의 할 일이다(다른 쪽의 1등이 나올 때까지)
import sys
sys.stdin = open('input.txt')
T = int(input())
for _ in range(T):
N = int(input())
count = 0
candidate = [list(map(int, input().split())) for _ in range(N)]
candidate.sort(key=lambda x:x[0])
answer = [candidate[0]]
for i in range(1, N):
if candidate[i][0]<=answer[-1][0] or candidate[i][1]<=answer[-1][1]:
answer.append(candidate[i])
print(len(answer))