https://www.acmicpc.net/problem/2535
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
def sol(n,nums):
nums.sort(key=lambda x: x[2],reverse=True)
nations=[0]*n
cnt=0
for i in range(len(nums)):
if cnt==3:
break
if nations[nums[i][0]]!=2:
nations[nums[i][0]]+=1
cnt+=1
print(nums[i][0],nums[i][1])
return nums
n=int(input())
nums=[ list(map(int, input().split())) for i in range(n)]
(sol(n,nums))
|
cs |
나라에 해당하는 인덱스 (LIne3) 생성 lambda를 이용해 정렬
Make Indices for Nations, using lambda sort
반응형
'python-algorithm' 카테고리의 다른 글
프로그래머스 배열의 평균값 (0) | 2022.10.19 |
---|---|
백준 2993 세 부분 (0) | 2022.10.18 |
백준 20124 모르고리즘 회장님 추천 받습니다 (0) | 2022.10.17 |
백준 23278 영화 평가 (0) | 2022.10.17 |
백준 25496 장신구 명장 임스 (0) | 2022.10.17 |
댓글