Skip to content

Commit 4e4be95

Browse files
committed
Solved: 2075 N번째 큰 수
1 parent e7ac9a1 commit 4e4be95

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# pypy3
2+
# 시간(ms) : 1028
3+
# 공간(KB) : 122816
4+
#
5+
# 공유 :
6+
# - int(1_000_000_000)은 약 29바이트
7+
# - 1500개 -> 약 0.05 MB
8+
# - 1500*1500개 -> 약 77 MB
9+
10+
11+
import sys
12+
import heapq
13+
input = sys.stdin.readline
14+
15+
pq = []
16+
n = int(input().strip())
17+
for _ in range(n):
18+
for x in list(map(int, input().strip().split())) :
19+
if len(pq) < n : heapq.heappush(pq, x) # 리스트가 n개 이하면 추가
20+
else : heapq.heappush(pq, max(x, heapq.heappop(pq))) # 리스트가 n개 이상이면 리스트의 가장 작은 값보다 크다면 추가
21+
print(heapq.nsmallest(1, pq)[0])

0 commit comments

Comments
 (0)