728x90
문제링크
https://school.programmers.co.kr/learn/courses/30/lessons/42889
코드
def solution(N, stages):
stages.sort()
result = {}
for i in range(N):
result[i+1] = 0
for i in stages:
try:
result[i] += 1
except:
break
downNum = len(stages)
print(result)
for i in range(N):
nextNum = result[i+1]
if downNum > 0:
result[i+1] = result[i+1] / downNum
downNum -= nextNum
else:
break
print(result)
resultList = sorted(result.items(), key=lambda x:x[1], reverse=True)
answer = []
for L in resultList:
answer.append(L[0])
return answer
728x90
'코딩테스트' 카테고리의 다른 글
정렬_심화24) 안테나 _ python (0) | 2023.09.25 |
---|---|
4주차 - 정렬 (0) | 2023.09.25 |
BFS&DFS_심화21) 인구이동 _ python (0) | 2023.09.25 |
BFS&DFS_심화20) 감시 피하기 _ python (0) | 2023.09.25 |
BFS&DFS_심화19) 연산자 끼워 넣기 _ python (0) | 2023.09.25 |