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 e7ac9a1 commit 4e4be95Copy full SHA for 4e4be95
INSEA-99/week06/2075_N번째_큰_수.py
@@ -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