problem-1946

ysysc·2022년 11월 29일
0

PS

목록 보기
37/47

과정
1. score에 등수를 튜플로 담고 서류 순서대로 오름차순 정렬
2. 이제 면접 등수를 기준으로 ans+=1
3. 이미 서류 순서대로 정렬되어있기 때문에 면접 등수가 기준보다 낮으면 앞설 수 있는 가능성이 없기 때문

import sys
input=sys.stdin.readline

t=int(input())
result=[]
for _ in range(t):
    n=int(input())
    score=[]
    for i in range(n):
        a,b=map(int,input().split())
        score.append((a,b))

    score.sort()
    ans=1
    temp=score[0][1]
    for x,y in score:
        if y<temp:
            ans+=1
            temp=y
    result.append(ans)
    

for r in result:
    print(r)

time:30분

0개의 댓글