본문 바로가기 메뉴 바로가기

뭐라도 해보자

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

뭐라도 해보자

검색하기 폼
  • 분류 전체보기 (486)
    • Diary (1)
    • (예전 글) (485)
      • PS (422)
      • CodeUp (22)
      • Algorithm Tutorial (11)
      • etc. (3)
      • [완료] 2023-2 Tutoring (7)
      • [완료] 구름톤 챌린지 (20)
  • 방명록

Priority-queue (1)
백준 1927번 - 최소 힙 [Python]

문제 링크 : https://www.acmicpc.net/problem/1927풀이 과정파이썬의 heapq 라이브러리를 이용해 풀이했다.전체 코드# 1927 : 최소 힙import sysimport heapqinput = sys.stdin.readlinen = int(input().rstrip())pq = []for _ in range(n): v = int(input().rstrip()) if v == 0: print(heapq.heappop(pq) if pq else 0) else: heapq.heappush(pq, v)

(예전 글)/PS 2025. 10. 16. 11:17
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • math
  • knapsack
  • BFS
  • number_theory
  • Greedy
  • bitmask
  • java
  • lca
  • backtracking
  • queue
  • codeup
  • BOJ
  • ad_hoc
  • segment-tree
  • Sort
  • Binary-Search
  • stack
  • lazy-propagation
  • sparse_table
  • string
  • C++
  • C
  • implementation
  • Prefix-Sum
  • PS
  • Python
  • bruteforcing
  • kmp
  • DP
  • 백준
more
«   2026/03   »
일 월 화 수 목 금 토
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바