'Baekjoon # Algorithm #Coding_Test #acmicpc.net #python3 #맥스힙 #max #heap'에 해당되는 글 1건

import sys

import heapq

 

heap = []

#파이썬의 경우 일반적인 input을 받게 될 경우 시간이 오래 걸린다.

n = int(sys.stdin.readline())

 

for i in range(0,n):

    x = int(sys.stdin.readline())

    fake_x = -x

    if x is 0:

        if len(heap) is 0:

            print(0)

        else:

            hhhh = (-1)*heapq.heappop(heap)

            print(hhhh)

 

    else:

        heapq.heappush(heap,fake_x)

블로그 이미지

BigJoon

간단 스크립트! 명쾌한 설명

,