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.
🅰 설계
명령(cmd)의 index와 해당 수를 저장하는 min-heap, max-heap. (max-heap은 num값을 음수로 저장)
cmd의 index가 삭제되었는지 여부를 저장하는 deleted 배열
dual priority queue의 사이즈를 의미하는 변수 size (0으로 초기화)
명령 처리
D일 때
size == 0이면 skip
size > 0
size 하나 줄인다
1일 때 (max)
max-heap에서 아직 삭제가 되지 않은 원소를 만날 때까지 while문 반복
-1일때
min-heap에서 아직 삭제가 되지 않은 원소를 만날 때까지 while문 반복
I 일때
size를 하나 증가시키고 min-heap에는 수를 그대로, max-heap에는 수를 음수로 저장
결과 출력
결과 출력
size가 0 초과일 경우 이미 삭제된 원소들을 제거 후 최댓/최솟값을 출력
✅ 후기