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

공작소

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

공작소

검색하기 폼
  • 분류 전체보기 (486)
    • 잡담 (1)
    • Problem Solving (24)
      • BOJ (24)
    • (예전 글) (461)
      • PS (398)
      • 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)

Problem Solving/BOJ 2025. 10. 16. 11:17
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • Sort
  • Python
  • C++
  • knapsack
  • Binary-Search
  • queue
  • Prefix-Sum
  • lca
  • implementation
  • Greedy
  • backtracking
  • DP
  • sparse_table
  • java
  • ad_hoc
  • bruteforcing
  • PS
  • bitmask
  • BFS
  • codeup
  • string
  • number_theory
  • lazy-propagation
  • C
  • BOJ
  • segment-tree
  • stack
  • kmp
  • 백준
  • math
more
«   2026/01   »
일 월 화 수 목 금 토
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

티스토리툴바