728x90
반응형

VERSION 2.0

import heapq
import sys


N ,k = list(map(int, sys.stdin.readline().split()))

x = list(map(int,sys.stdin.readline().split()))



heapq.heapify(x)
# print(x)

for i in range(len(x)-k):
    heapq.heappop(x)

print(heapq.heappop(x))

==> heapq.heapify(x) ==> 리스트 x를 heap화 한다!!!

==> heapq.heappop() 할시 ==> 작은값을 먼저 뽑아낸다!!!!!

VERSION 1.0

import sys


N = list(map(int, sys.stdin.readline().split()))

A = list(map(int, sys.stdin.readline().split()))

b = sorted(A , reverse = True)
print(b[N[1]-1])

별게 없다. 동점자여도 그냥 2번째꺼 뽑아내면 된다.

728x90
반응형

+ Recent posts