- 키와 몸무게 중 적어도 하나는 다른 멤버보다 뛰어나야 한다
- 키를 기준으로 내림 차순으로 정렬하거나 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
'Data Structures & Algorithms' 카테고리의 다른 글
[Algorithms] 결정&그리디 알고리즘-역수열(그리디 알고리즘) (0) | 2022.05.17 |
---|---|
[Algorithms] 결정&그리디 알고리즘-침몰하는 타이타닉(그리디 알고리즘) (0) | 2022.05.16 |
[Algorithms] 결정&그리디 알고리즘-회의실 배정(그리디 알고리즘) (0) | 2022.05.16 |
[Algorithms] 결정&그리디 알고리즘-마구간 정하기(결정 알고리즘) (0) | 2022.05.15 |
[Algorithms] 결정&그리디 알고리즘-뮤직비디오(결정 알고리즘) (0) | 2022.05.15 |