diff --git a/H0ngJu/README.md b/H0ngJu/README.md index 1080678..d0ad384 100644 --- a/H0ngJu/README.md +++ b/H0ngJu/README.md @@ -24,7 +24,7 @@ | 20차시 | 2024.06.03 | 백트래킹 | [스타트와 링크](https://www.acmicpc.net/problem/14889) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/206 | | 21차시 | 2024.06.07 | 그리디 | [행복 유치원](https://www.acmicpc.net/problem/13164) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/208 | | 22차시 | 2024.08.06 | 해시 | [의상](https://school.programmers.co.kr/learn/courses/30/lessons/42578) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/224 | - +| 23차시 | 2024.08.10 | 해시 | [베스트앨범](https://school.programmers.co.kr/learn/courses/30/lessons/42579) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/227 | | 24차시 | 2024.08.17 | BFS | [아기상어](https://www.acmicpc.net/problem/16236) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/233 | --- diff --git "a/H0ngJu/\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.py" "b/H0ngJu/\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.py" new file mode 100644 index 0000000..2a7eb9a --- /dev/null +++ "b/H0ngJu/\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.py" @@ -0,0 +1,34 @@ +genres = ["classic", "pop", "classic", "classic", "pop", "ex", "ex"] +plays = [500, 600, 150, 800, 2500, 900, 400] +answer = [] +f = 0 + +dic = {} +info = {} + +for i in range(len(genres)): + g = genres[i] + p = plays[i] + + info[i] = g + + if g in dic: + dic[g] += p + else: + dic[g] = p + +best_g = sorted(dic.items(), key=lambda x: x[1], reverse=True) + +for g, _ in best_g: + if f == 2: break + best_album = [(plays[i], i) for i in range(len(genres)) if genres[i] == g] + for i in range(len(best_album)): + for j in range(i+1, len(best_album)): + if best_album[j][0] > best_album[i][0]: #재생수가 작은 경우 + best_album[i], best_album[j] = best_album[j], best_album[i] + + answer.extend([x[1] for x in best_album[:2]]) + f += 1 + + +print(answer) \ No newline at end of file