Skip to content

Commit 972ef02

Browse files
committed
[level 1] Title: 명예의 전당 (1), Time: 0.26 ms, Memory: 11.5 MB -BaekjoonHub
1 parent ec11c61 commit 972ef02

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

프로그래머스/1/138477. 명예의 전당 (1)/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 10.1 MB, 시간: 0.01 ms
7+
메모리: 11.5 MB, 시간: 0.26 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2024년 07월 12일 17:28:23
19+
2026년 07월 25일 15:14:12
2020

2121
### 문제 설명
2222

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import heapq
2+
13
def solution(k, score):
2-
q = []
3-
answer = []
4-
for s in score:
5-
q.append(s)
6-
if (len(q) > k):
7-
q.remove(min(q))
8-
answer.append(min(q))
9-
return answer
4+
h = []
5+
ans = []
6+
for i in score:
7+
heapq.heappush(h, i)
8+
if len(h) > k:
9+
heapq.heappop(h)
10+
ans.append(h[0])
11+
return ans

0 commit comments

Comments
 (0)