Skip to content

Commit

Permalink
Merge pull request #227 from AlgoLeadMe/23-H0ngJu
Browse files Browse the repository at this point in the history
23-H0ngJu
  • Loading branch information
H0ngJu authored Aug 21, 2024
2 parents 883f980 + 2dd22df commit 81f4b15
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

---
34 changes: 34 additions & 0 deletions H0ngJu/๋ฒ ์ŠคํŠธ์•จ๋ฒ”.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 81f4b15

Please sign in to comment.