Skip to content

Commit

Permalink
add 2963
Browse files Browse the repository at this point in the history
  • Loading branch information
5d-jh committed Mar 27, 2022
1 parent b31cb3b commit e435e47
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions sorting/2963.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## 백준 2963
https://www.acmicpc.net/problem/2963

> 배열 A가 주어졌을 때, N번째 큰 값을 출력하는 프로그램을 작성하시오.

### 소스코드
```py
import heapq
from typing import List


T = int(input())

def solve(A: List[int]):
hq = list(map(lambda a: -a, A))
heapq.heapify(hq)

for _ in range(2):
heapq.heappop(hq)

return -heapq.heappop(hq)


for _ in range(T):
A = list(map(int, input().split()))

print(solve(A))


```

### 해설
입력받은 배열을 heapify한 다음 heappop을 3번 수행한 결과값을 리턴한다.

0 comments on commit e435e47

Please sign in to comment.