λ¬Έμ
https://www.acmicpc.net/problem/11279
11279λ²: μ΅λ ν
첫째 μ€μ μ°μ°μ κ°μ N(1 ≤ N ≤ 100,000)μ΄ μ£Όμ΄μ§λ€. λ€μ Nκ°μ μ€μλ μ°μ°μ λν μ 보λ₯Ό λνλ΄λ μ μ xκ° μ£Όμ΄μ§λ€. λ§μ½ xκ° μμ°μλΌλ©΄ λ°°μ΄μ xλΌλ κ°μ λ£λ(μΆκ°νλ) μ°μ°μ΄κ³ , xκ°
www.acmicpc.net
νμ΄
# λ°±μ€ 11279λ² λ¬Έμ - μ΅λ ν
import sys
import heapq
n= int(input())
heap = []
for _ in range(n) :
x = int(sys.stdin.readline())
if x :
heapq.heappush(heap, (-x, x))
else :
if len(heap) >= 1 :
print(heapq.heappop(heap)[1])
else :
print(0)
'ποΈ Algorithm > π© λ°±μ€' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
π© [λ°±μ€] [Python] [Class3] 18870λ²_μ’ν μμΆ (0) | 2022.11.07 |
---|---|
π© [λ°±μ€] [Python] [Class3] 11724λ²_μ°κ²° μμμ κ°μ (0) | 2022.11.07 |
π© [λ°±μ€] [Python] [ꡬν] 2167λ²_2μ°¨μ λ°°μ΄μ ν© (0) | 2022.11.06 |
π© [λ°±μ€] [Python] [ꡬν] 17478λ²_μ¬κ·ν¨μκ° λκ°μ? (0) | 2022.11.06 |
π© [λ°±μ€] [Python] [ꡬν] 1475λ²_λ°© λ²νΈ (0) | 2022.11.05 |