[백준 2075] - Python

골솔·2021년 3월 5일
0

알고문제풀기

목록 보기
13/27

취알스 10주차 우선순위 큐, 힙, 트리 요약 - 3/4

2075 N번째 큰 수

import sys
import heapq
input = sys.stdin.readline

n = int(input())
table=[]
for i in range(n):
    table.append(list(map(int, input().split())))
heap = []
for i in range(n):
    for j in range(n):
        heapq.heappush(heap, table[i][j])
        if len(heap)>n:
            heapq.heappop(heap)
print(heap[0])

주의

pypy3로 제출해야 함. python3로 제출하면 메모리 초과 발생

profile
골때리는이솔

0개의 댓글