https://www.acmicpc.net/problem/2535
2535번: 아시아 정보올림피아드
첫 번째 줄에는 대회참가 학생 수를 나타내는 N이 주어진다. 단, 3 ≤ N ≤ 100이다. 두 번째 줄부터 N개의 줄에는 각 줄마다 한 학생의 소속 국가 번호, 학생 번호, 그리고 성적이 하나의 빈칸을 사
www.acmicpc.net
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 |
댓글