- Notifications
You must be signed in to change notification settings - Fork 846
/
Copy path3.py
25 lines (20 loc) · 763 Bytes
/
3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
defsolution(N, stages):
answer= []
length=len(stages)
# 스테이지 번호를 1부터 N까지 증가시키며
foriinrange(1, N+1):
# 해당 스테이지에 머물러 있는 사람의 수 계산
count=stages.count(i)
# 실패율 계산
iflength==0:
fail=0
else:
fail=count/length
# 리스트에 (스테이지 번호, 실패율) 원소 삽입
answer.append((i, fail))
length-=count
# 실패율을 기준으로 각 스테이지를 내림차순 정렬
answer=sorted(answer, key=lambdat: t[1], reverse=True)
# 정렬된 스테이지 번호 반환
answer= [i[0] foriinanswer]
returnanswer