From 2a31104eb96bdfd1e554de7d82e480d3ad1a68bf Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Tue, 18 Nov 2025 23:52:24 +0900 Subject: [PATCH] =?UTF-8?q?[20251118]=20PGM=20/=20LV2=20/=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EC=84=B8=EC=8A=A4=20/=20=EC=9D=B4=EC=9D=B8=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...04\353\241\234\354\204\270\354\212\244.md" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "LiiNi-coder/202511/18 PGM \355\224\204\353\241\234\354\204\270\354\212\244.md" diff --git "a/LiiNi-coder/202511/18 PGM \355\224\204\353\241\234\354\204\270\354\212\244.md" "b/LiiNi-coder/202511/18 PGM \355\224\204\353\241\234\354\204\270\354\212\244.md" new file mode 100644 index 00000000..5fdbb7e1 --- /dev/null +++ "b/LiiNi-coder/202511/18 PGM \355\224\204\353\241\234\354\204\270\354\212\244.md" @@ -0,0 +1,38 @@ +```java +import java.util.*; + +class Solution { + public int solution(int[] priorities, int location) { + PriorityQueue pq = new PriorityQueue<>( Collections.reverseOrder()); + for(int p : priorities){ + pq.offer(p); + } + int printedCount = 0; + Deque queue = new ArrayDeque<>(); + for(int i = 0; i < priorities.length; i++){ + queue.offerLast(new int[]{ i, priorities[i] }); + } + + while(!queue.isEmpty()){ + int[] now = queue.pollFirst(); + int index = now[0]; + int pri = now[1]; + + if(pri == pq.peek()){ + pq.poll(); + printedCount++; + if(index == location){ + return printedCount; + } + } + + //다시 큐 보내기 + else { + queue.offerLast(now); + } + } + return printedCount; + } +} + +```