๋ฐ์ํ
๐ค๋ฌธ์ ํด๊ฒฐ
-
S2 | ์๋ฃ๊ตฌ์กฐ, ์ฐ์ ์์ ํ
์ต๋ํ ์๋ฃ๊ตฌ์กฐ๋ฅผ ํ์ฉํ๋ ๋ฌธ์
ํ์ง๋ง ๊ท์ฐฎ์ผ๋ฏ๋ก ํํ ๋ชจ๋์ ์ฌ์ฉํ๋ค.
๐ป์์ค ์ฝ๋
import sys
import heapq
N = int(input())
numbers = []
for i in range(N):
number = int(sys.stdin.readline())
if number:
heapq.heappush(numbers, -number)
else:
if numbers:
print(abs(heapq.heappop(numbers)))
else:
print(0)
๐๋ฌธ์ ํ์ธ
์ถ์ฒ: BACKJOON ONLINE JUDGE
๋งํฌ: https://www.acmicpc.net/problem/11279
๋ฐ์ํ
'Algorithm Problem > Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[python] ๋ฐฑ์ค - 1890. ์ ํ (0) | 2020.10.12 |
---|---|
[python] ๋ฐฑ์ค - 1780. ์ข ์ด์ ๊ฐ์ (0) | 2020.10.11 |
[python] ๋ฐฑ์ค - 10819. ์ฐจ์ด๋ฅผ ์ต๋๋ก (0) | 2020.10.09 |
[python] ๋ฐฑ์ค - 1541. ์์ด๋ฒ๋ฆฐ ๊ดํธ (0) | 2020.10.08 |
[python] ๋ฐฑ์ค - 2133. ํ์ผ ์ฑ์ฐ๊ธฐ (1) | 2020.10.07 |