Hanbit the Developer

[그리디] Python - 1946번, 신입 사원 본문

Algorithm/백준

[그리디] Python - 1946번, 신입 사원

hanbikan 2021. 3. 3. 12:16
T = int(input())
for _ in range(T):
    N = int(input())
    scores = [0]*(N+1)
    for _ in range(N):
        curDoc, curInt = map(int, input().split())
        scores[curDoc] = curInt
    
    minInt = scores[1]
    cntDropout = 0
    for i in range(2, N+1):
        if scores[i] > minInt:
            cntDropout += 1
        else:
            minInt = scores[i]
    print(N-cntDropout)

중복이 없는 등수로 입력되므로(1...N) 서류 점수를 index로 하고 인터뷰를 value로 가지는 배열을 만들어서 넣는다.

다음으로, 서류 점수를 의미하는 index를 1부터 끝까지 도는데, index가 증가될수록 등수가 낮아진다는 것이므로 서류 점수는 이전 것들에 비해 높아야한다.