지나가던 개발자
[Python] 백준 2535번(아시아 정보올림피아드) 문제 풀이 본문
players = []
for i in range(int(input())):
players.append(list(reversed(list(map(int, input().split(" "))))))
players = sorted(players, reverse=True)
printed_country = []
i = 0
while True:
if printed_country.count(players[i][2]) < 2:
print(players[i][2], players[i][1])
printed_country.append(players[i][2])
if len(printed_country) == 3:
break
i += 1
2차원 배열을 sort하면 0번째 인덱스를 기준으로 정렬된다. 사실 그냥 key를 사용해서 2번째 인덱스(점수)를 기준으로 정렬할 수도 있지만, 그냥 reverse해서 뒤집은 다음에 sort했다.
'PS > Python' 카테고리의 다른 글
[Python] 백준 4150번(피보나치 수) 문제 풀이 (0) | 2022.09.04 |
---|---|
[Python] 백준 2028번(자기복제수) 문제 풀이 (0) | 2022.09.03 |
[Python] 백준 10448번(유레카 이론) 문제 풀이 (0) | 2022.08.30 |
[Python] 백준 5026번(박사 과정) 문제 풀이 (0) | 2022.08.27 |
[Python] 백준 9375번(패션왕 신혜빈) 문제 풀이 (0) | 2022.08.27 |
Comments