Algorithm

백준 2075번: N번째 큰 수 (S3) - Python 풀이

서서리 2025. 1. 21. 00:09
SMALL

문제 설명

https://www.acmicpc.net/problem/2075

정답 코드

import heapq

N = int(input())
heap = []

for _ in range(N):
    for i in list(map(int, input().split())):
        if len(heap) == N and i > heap[0]:
            heapq.heappush(heap, i)
            heapq.heappop(heap)
        elif len(heap) < N:
            heapq.heappush(heap, i)

print(heap[0])
LIST