From 8a826d6ac9d33c18adbad54b561e913c56447c8d Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Mon, 2 Jun 2025 15:26:31 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[PGS]=20=EB=94=94=EC=8A=A4=ED=81=AC=20?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC(Python)=20/=20Level=203=20?= =?UTF-8?q?/=2060=EB=B6=84=20/=20=ED=9E=8C=ED=8A=B8,=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50\355\212\270\353\241\244\353\237\254.py" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "minjeong/Heap/2025-06-01-[PGS]-\353\224\224\354\212\244\355\201\254\354\273\250\355\212\270\353\241\244\353\237\254.py" diff --git "a/minjeong/Heap/2025-06-01-[PGS]-\353\224\224\354\212\244\355\201\254\354\273\250\355\212\270\353\241\244\353\237\254.py" "b/minjeong/Heap/2025-06-01-[PGS]-\353\224\224\354\212\244\355\201\254\354\273\250\355\212\270\353\241\244\353\237\254.py" new file mode 100644 index 0000000..bbc8343 --- /dev/null +++ "b/minjeong/Heap/2025-06-01-[PGS]-\353\224\224\354\212\244\355\201\254\354\273\250\355\212\270\353\241\244\353\237\254.py" @@ -0,0 +1,29 @@ +import heapq + +def solution(jobs): + jobs.sort() # 요청시간 기준 정렬 + job_len = len(jobs) + i = 0 # jobs 인덱스 + end_time = 0 # 현재 시간 + return_time = 0 # 작업 반환 시간 + count = 0 # 작업 처리한 개수 + + heap = [] + + while count < job_len: + # 현재 시간에 요청된 작업 처리 + while i < job_len and jobs[i][0] <= end_time: + heapq.heappush(heap, (jobs[i][1], jobs[i][0], i)) # 소요시간, 요청시간, 작업번호 순서 + i += 1 + + # 대기 큐에 작업이 있다면, 시간을 업데이트한다. + if len(heap) > 0: + work_time, start_time, num = heapq.heappop(heap) + end_time += work_time + return_time += end_time - start_time + count += 1 + else: + # 대기 큐가 비었다면, 다음 작업이 올 때까지 기다려야 한다. + end_time = jobs[i][0] + + return return_time // job_len \ No newline at end of file From 4f219f37f80db5ed4e7a0cb5a95ba3a95bcf6aaf Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Tue, 3 Jun 2025 09:03:48 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[BOJ]=20#14698.=20=EC=A0=84=EC=83=9D?= =?UTF-8?q?=ED=96=88=EB=8D=94=EB=8B=88=20=EC=8A=AC=EB=9D=BC=EC=9E=84=20?= =?UTF-8?q?=EC=97=B0=EA=B5=AC=EC=9E=90=EC=98=80=EB=8D=98=20=EA=B2=83?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=98=EC=97=AC(Hard)=20/=20=EA=B3=A8?= =?UTF-8?q?=EB=93=9C4=20/=2020=EB=B6=84=20/=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\214\200\355\225\230\354\227\254(Hard).py" | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 "minjeong/Heap/2025-06-02-[\353\260\261\354\244\200]-#14698-\354\240\204\354\203\235\355\226\210\353\215\224\353\213\210\354\212\254\353\235\274\354\236\204\354\227\260\352\265\254\354\236\220\354\230\200\353\215\230\352\261\264\354\227\220\353\214\200\355\225\230\354\227\254(Hard).py" diff --git "a/minjeong/Heap/2025-06-02-[\353\260\261\354\244\200]-#14698-\354\240\204\354\203\235\355\226\210\353\215\224\353\213\210\354\212\254\353\235\274\354\236\204\354\227\260\352\265\254\354\236\220\354\230\200\353\215\230\352\261\264\354\227\220\353\214\200\355\225\230\354\227\254(Hard).py" "b/minjeong/Heap/2025-06-02-[\353\260\261\354\244\200]-#14698-\354\240\204\354\203\235\355\226\210\353\215\224\353\213\210\354\212\254\353\235\274\354\236\204\354\227\260\352\265\254\354\236\220\354\230\200\353\215\230\352\261\264\354\227\220\353\214\200\355\225\230\354\227\254(Hard).py" new file mode 100644 index 0000000..e083c75 --- /dev/null +++ "b/minjeong/Heap/2025-06-02-[\353\260\261\354\244\200]-#14698-\354\240\204\354\203\235\355\226\210\353\215\224\353\213\210\354\212\254\353\235\274\354\236\204\354\227\260\352\265\254\354\236\220\354\230\200\353\215\230\352\261\264\354\227\220\353\214\200\355\225\230\354\227\254(Hard).py" @@ -0,0 +1,21 @@ +import sys +import heapq +input = sys.stdin.readline + +T = int(input()) +for _ in range(T): + total = 1 + N = int(input()) + heap = list(map(int, input().split())) + if N == 1: + print(1) + continue + + heapq.heapify(heap) + + while len(heap) > 1: + energy = heapq.heappop(heap) * heapq.heappop(heap) + total *= energy + heapq.heappush(heap, energy) + + print(total % 1000000007) \ No newline at end of file From 8c38a8c576ffd4764aa02480b3996ce3bf71c98f Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Sat, 7 Jun 2025 13:03:02 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[BOJ]=20#1715.=20=EC=B9=B4=EB=93=9C=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=ED=95=98=EA=B8=B0=20/=20=EA=B3=A8=EB=93=9C4?= =?UTF-8?q?=20/=205=EB=B6=84=20/=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\225\353\240\254\355\225\230\352\270\260.py" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 "minjeong/Heap/2025-06-06-[\353\260\261\354\244\200]-#1715-\354\271\264\353\223\234\354\240\225\353\240\254\355\225\230\352\270\260.py" diff --git "a/minjeong/Heap/2025-06-06-[\353\260\261\354\244\200]-#1715-\354\271\264\353\223\234\354\240\225\353\240\254\355\225\230\352\270\260.py" "b/minjeong/Heap/2025-06-06-[\353\260\261\354\244\200]-#1715-\354\271\264\353\223\234\354\240\225\353\240\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..26f3be4 --- /dev/null +++ "b/minjeong/Heap/2025-06-06-[\353\260\261\354\244\200]-#1715-\354\271\264\353\223\234\354\240\225\353\240\254\355\225\230\352\270\260.py" @@ -0,0 +1,16 @@ +import sys +import heapq +input = sys.stdin.readline + +N = int(input()) +cards = [int(input()) for _ in range(N)] +answer = 0 +heapq.heapify(cards) + +while len(cards) > 1: + a = heapq.heappop(cards) + b = heapq.heappop(cards) + answer += a + b + heapq.heappush(cards, a+b) + +print(answer) \ No newline at end of file