Data Structures & Algorithms
[Algorithms] 결정&그리디 알고리즘-씨름 선수(그리디 알고리즘)
숄구-ml
2022. 5. 16. 16:51
- 키와 몸무게 중 적어도 하나는 다른 멤버보다 뛰어나야 한다
- 키를 기준으로 내림 차순으로 정렬하거나 or 몸무게를 기준으로 내림차순으로 정렬해서 sorting을 시작한다
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import sys
sys.stdin = open("input", "rt")
n = int(input())
personInfo = [list(map(int, input().split())) for _ in range(n)]
personInfo.sort(reverse=True)
cnt=0
max_weight=0
for height, weight in personInfo:
if weight > max_weight:
cnt+=1
max_weight=weight
print(cnt)
|
cs |
728x90