We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7ddeca7 commit ff7caabCopy full SHA for ff7caab
JongHo/Programmers/42579.py
@@ -0,0 +1,26 @@
1
+def solution(genres, plays):
2
+ answer = []
3
+ genre = list(set(genres))
4
+ arr = dict()
5
+ public = [[] for _ in range(len(genre))]
6
+
7
+ for i in genre:
8
+ arr[i] = 0
9
+ # 각 장르마다 총 플레이 횟수 구함.
10
+ for idx, i in enumerate(genres):
11
+ arr[i] += plays[idx]
12
+ # public리스트에 현재 장르의 총 플레이횟수, 현재 노래 플레이횟수, 고유번호를 저장.
13
+ for idx, i in enumerate(zip(genres, plays)):
14
+ public[genre.index(i[0])].append([arr[i[0]], i[1], idx])
15
+ # 주어진 조건대로 정렬한다.
16
+ for i in range(len(public)):
17
+ public[i].sort(reverse = True, key = lambda x : (x[1], -x[2]))
18
+ if len(public[i]) > 2:
19
+ public[i] = public[i][:2]
20
+ public.sort(reverse=True, key=lambda x : x[0])
21
22
+ for i in public:
23
+ for j in i:
24
+ answer.append(j[2])
25
26
+ return answer
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments