백준 1946번
각 입사 후보자들의 시험 점수를 주어준 후, 누군가의 하위호완이 되는 사람은 후보에서 제외한다.
시험 점수는 2종류이다.
import sys
input = sys.stdin.readline
def n_safe(scores, people):
answer = 1
# sort w.r.t paper score rank
sort_paper = sorted(scores)
interview_rank_top_paper = sort_paper[0][1]
if interview_rank_top_paper < 3: # the case: top paper + top interview both.
return interview_rank_top_paper
# sort w.r.t interview score rank
sort_interview = sorted(sort_paper, key = lambda x:x[1])[:interview_rank_top_paper]
for paper, interview in sort_interview[1:]:
if paper < sort_interview[0][0]:
answer += 1
return answer
n_problems = int(input())
answer = []
for problem in range(n_problems):
people = int(input())
scores = []
for person in range(people):
scores.append(list(map(int,input().split())))
if people > 1:
answer.append(n_safe(scores,people))
else:
answer.append(1)
print("\n".join(map(str,answer)))
--> 틀림