import sys
import heapq
max_heap = []
min_heap = []
for _ in range(int(input())):
num = int(sys.stdin.readline())
if len(max_heap) == len(min_heap):
heapq.heappush(max_heap, (-num, num))
else:
heapq.heappush(min_heap, (num, num))
if min_heap and max_heap[0][1] > min_heap[0][1]:
max_value = heapq.heappop(max_heap)[1]
min_value = heapq.heappop(min_heap)[1]
heapq.heappush(min_heap, (max_value, max_value))
heapq.heappush(max_heap, (-min_value, min_value))
print(max_heap[0][1])
'코딩테스트 > BOJ' 카테고리의 다른 글
[BOJ] 16929 Two Dots (python) (0) | 2020.09.03 |
---|---|
[BOJ] 10026 적록색약 (python) (0) | 2020.09.03 |
백준 #5052 전화번호목록 (Python) (0) | 2020.04.16 |
백준 #13549 숨바꼭질3 (Python) (0) | 2020.04.12 |
백준 #9251 LCS [Python] (0) | 2020.03.27 |