Conversation
ttps://school.programmers.co.kr/learn/courses/30/lessons/42627
ttps://school.programmers.co.kr/learn/courses/30/lessons/42627
Mingguriguri
approved these changes
Jul 6, 2025
Collaborator
Mingguriguri
left a comment
There was a problem hiding this comment.
이번 문제는 자주 풀어보지 않은 유형이기도 하고 난이도도 있어서 아마 푸는 데 쉽지 않으셨을거예요.. 그럼에도 잘 풀어주셨네요!! 너무 고생 많으셨습니다!
Hongjoo/lv3/디스크컨트롤러.py
Outdated
Collaborator
There was a problem hiding this comment.
작업의 결과를 리스트에 저장하고 리스트의 길이를 answer에 나눠서 answer로 반환하는 점이 다른 코드랑 달라서 새로워서 좋네용!
Hongjoo/lv3/디스크컨트롤러.py
Outdated
Comment on lines
+1
to
+14
Collaborator
There was a problem hiding this comment.
문제 풀이 과정을 이렇게 항상 정리해두시는데 코드 이해하는데 도움이 되는 것 같아요! 👍🏻
Collaborator
There was a problem hiding this comment.
Hongjoo/lv3/이중우선순위큐.py
Outdated
Comment on lines
+18
to
+34
Collaborator
There was a problem hiding this comment.
저는 최소힙, 최대힙 2개라 나누고 동기화(number_count에 카운트)해가면서 풀이했는데 하나의 heap에 풀이하셨군요!
if cmd == 'I':
# 삽입
heapq.heappush(min_heap, num)
heapq.heappush(max_heap, -num)
number_count[num] = number_count.get(num, 0) + 1
size += 1
else: # cmd == 'D'
if size == 0:
# 큐가 비어있다면 연산 무시
continue
if num == 1:
# 최댓값 삭제
while max_heap:
x = -heapq.heappop(max_heap)
if number_count.get(x, 0) > 0:
# num이 1번 이상 등장했다면, 카운트 반영
number_count[x] -= 1
size -= 1
break
else:
# num == -1, 최솟값 삭제
while min_heap:
x = heapq.heappop(min_heap)
if number_count.get(x, 0) > 0:
# num이 1번 이상 등장했다면, 카운트 반영
number_count[x] -= 1
size -= 1
break
Hongjoo/lv3/이중우선순위큐.py
Outdated
🔥2025-07 챌린지 진행 상황👉 그리디
👉 구현
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🌱WIL
🚀주간 목표 문제 수:4 개
프로그래머스 #42627. 디스크컨트롤러: 구현,우선순위큐/ lv3
정리한 링크: (바로가기)
🚩플로우 (선택)
time += 1 로 wait 큐와 HD 할당을 각 시각별로 확인 및 처리
wait 큐에 요청 시각에 맞춰 작업 할당하기
HD 작업 진행 여부 확인(hd_timdout)
[1] HD 작업 진행 중
[2] HD 작업 완료(hd_timeout=0) 및 비어 있을때 (hd_timeout = -1)
(1) 진행 중인 HD 작업 완료 시
(2) Wait 큐가 jobs가 있으면 wait 큐에서 우선순위 작업 뽑아 HD에 할당하기
작업 반환 시간(turnaround_time , 요청시간 - 완료 시간) 에 대해 출력 형태 맞추기
🚩제출한 코드
💡TIL
프로그래머스 #42628. 이중우선순위큐: 구현,우선순위큐/ lv3
정리한 링크: (바로가기)
🚩플로우 (선택)
문제에 주어진 이중우선순위 큐 함수를 정의한다.
[3가지 동작]
(1) 큐에 숫자 삽입하기
I 숫자:(2) 큐에서 최소값 삭제하기 (
D -1)(3) 큐에서 최대값 삭제하기 (
D 1)입력 명령문에 대해 반복문을 실행한다.
최종 큐의 상태에 따라 출력 형태를 변형한다.
case1. 큐에 요소가 2개 이상 존재하면-> 최대값 & 최소값 출력
case2. 큐가 비어 있으면 → [0,0
case3. 큐에 요소가 1개만 존재하면 → [값, 값]
🚩제출한 코드
💡TIL