본문 바로가기
Problem Solving/BOJ

[Priority Queue] python 2075 N번째 큰 수

by Bokoo14 2023. 2. 9.

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

 

2075번: N번째 큰 수

첫째 줄에 N(1 ≤ N ≤ 1,500)이 주어진다. 다음 N개의 줄에는 각 줄마다 N개의 수가 주어진다. 표에 적힌 수는 -10억보다 크거나 같고, 10억보다 작거나 같은 정수이다.

www.acmicpc.net

# 2023.02.09
import sys
input = sys.stdin.readline
import heapq

n = int(input())

h = []
for i in range(n):
    num = list(map(int, input().split()))
    for j in range(n):
        if len(h)<n:
            heapq.heappush(h, num[j])
        else:
            if h[0]<num[j]:
                heapq.heappop(h)
                heapq.heappush(h, num[j])

print(h[0])

'Problem Solving > BOJ' 카테고리의 다른 글

[DP] python 9251 LCS  (0) 2023.02.08
[DP] python 2156 포도주 시식  (0) 2023.02.07
[Binary Search] python 10815 숫자 카드  (0) 2023.02.05
[Two Pointer] python 1806 부분합  (0) 2023.02.04
[문자열] python 20437 문자열 게임2  (2) 2023.02.03