From 13e2521f6949daa1fcac5ab6127be2c09a980d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Sun, 26 May 2024 22:14:02 +0900 Subject: [PATCH 1/6] =?UTF-8?q?27=EC=B0=A8=EC=8B=9C=20=EB=AC=B8=EC=A0=9C?= =?UTF-8?q?=20=EC=84=A0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\232\260\354\204\240\354\210\234\354\234\204-\355\201\220.py" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "alstjr7437/\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220/\354\235\264\354\244\221-\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220.py" diff --git "a/alstjr7437/\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220/\354\235\264\354\244\221-\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220.py" "b/alstjr7437/\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220/\354\235\264\354\244\221-\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220.py" new file mode 100644 index 00000000..e69de29b From 1154ee36d5ff4fdc5a57c6d48067cb8b97697e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Mon, 27 May 2024 02:38:49 +0900 Subject: [PATCH 2/6] =?UTF-8?q?27=EC=B0=A8=EC=8B=9C=20solved?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alstjr7437/README.md | 3 +- ...0\354\210\234\354\234\204-\355\201\220.py" | 47 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/alstjr7437/README.md b/alstjr7437/README.md index 7dd371bc..7a444049 100644 --- a/alstjr7437/README.md +++ b/alstjr7437/README.md @@ -27,4 +27,5 @@ | 23차시 | 2024.05.01 | 큐 | 프로세스 | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/79 | | 24차시 | 2024.05.14 | BFS | 토마토 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/187 | | 25차시 | 2024.05.18 | 덱 | AC | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/190 | -| 26차시 | 2024.05.22 | 정렬 | H-Index | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/196 | \ No newline at end of file +| 26차시 | 2024.05.22 | 정렬 | H-Index | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/196 | +| 27차시 | 2024.05.26 | 우선순위 큐 | 이중 우선순위 큐 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/198 | \ No newline at end of file diff --git "a/alstjr7437/\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220/\354\235\264\354\244\221-\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220.py" "b/alstjr7437/\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220/\354\235\264\354\244\221-\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220.py" index e69de29b..a1ac59d8 100644 --- "a/alstjr7437/\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220/\354\235\264\354\244\221-\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220.py" +++ "b/alstjr7437/\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220/\354\235\264\354\244\221-\354\232\260\354\204\240\354\210\234\354\234\204-\355\201\220.py" @@ -0,0 +1,47 @@ +from heapq import * +import sys + +input = sys.stdin.readline + +t = int(input()) + +for _ in range(t): + q = int(input()) + + # 최소힙만 지원해서 최대, 최소 만들어주기 + min_heap = [] + max_heap = [] + nums = [False] * q # 동기화를 위한 부분 + + for i in range(q): + k = list(input().split()) + iNum = int(k[1]) + + # 입력 부분 + if k[0] == "I" : + heappush(min_heap, (iNum,i)) # 동기화를 위한 i도 튜플로 넣어주기 + heappush(max_heap, (-iNum, i)) + nums[i] = True + elif iNum == 1: + while max_heap and not nums[max_heap[0][1]]: + heappop(max_heap) + if max_heap: # max_heap에서 작은 수 제거 + nums[max_heap[0][1]] = False + heappop(max_heap) + else: + while min_heap and not nums[min_heap[0][1]]: # 이미 삭제된 노드인 경우 삭제되지 않은 노드 나올때까지 모두 버림 + heappop(min_heap) + if min_heap: # min_heap에서 작은 수(삭제 노드) 제거 + nums[min_heap[0][1]] = False + heappop(min_heap) + # print(min_heap, max_heap, nums, k) + # 모든 연산 후 동기화 되지 않은 노드 처리 + while min_heap and not nums[min_heap[0][1]]: + heappop(min_heap) + while max_heap and not nums[max_heap[0][1]]: + heappop(max_heap) + + if max_heap and min_heap : + print(-max_heap[0][0], min_heap[0][0]) + else : + print("EMPTY") \ No newline at end of file From eed3fa094aff3c807dda3daed56f74f94035d84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Fri, 31 May 2024 02:21:31 +0900 Subject: [PATCH 3/6] =?UTF-8?q?28=EC=B0=A8=EC=8B=9C=20=EB=AC=B8=EC=A0=9C?= =?UTF-8?q?=20=EC=84=A0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alstjr7437/README.md | 3 ++- .../\354\271\264\354\236\211-\353\213\254\353\240\245.py" | 0 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 "alstjr7437/\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/\354\271\264\354\236\211-\353\213\254\353\240\245.py" diff --git a/alstjr7437/README.md b/alstjr7437/README.md index 7a444049..b413e42f 100644 --- a/alstjr7437/README.md +++ b/alstjr7437/README.md @@ -28,4 +28,5 @@ | 24차시 | 2024.05.14 | BFS | 토마토 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/187 | | 25차시 | 2024.05.18 | 덱 | AC | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/190 | | 26차시 | 2024.05.22 | 정렬 | H-Index | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/196 | -| 27차시 | 2024.05.26 | 우선순위 큐 | 이중 우선순위 큐 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/198 | \ No newline at end of file +| 27차시 | 2024.05.26 | 우선순위 큐 | 이중 우선순위 큐 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/198 | +| 28차시 | 2024.05.30 | 브루트 포스 | 카잉 달력 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/203 | \ No newline at end of file diff --git "a/alstjr7437/\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/\354\271\264\354\236\211-\353\213\254\353\240\245.py" "b/alstjr7437/\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/\354\271\264\354\236\211-\353\213\254\353\240\245.py" new file mode 100644 index 00000000..e69de29b From e2eda50f97f1faab4a8b4feeca0ad23861e315ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Fri, 31 May 2024 02:28:04 +0900 Subject: [PATCH 4/6] =?UTF-8?q?28=EC=B0=A8=EC=8B=9C=20=EB=AC=B8=EC=A0=9C?= =?UTF-8?q?=20solved?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...64\354\236\211-\353\213\254\353\240\245.py" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git "a/alstjr7437/\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/\354\271\264\354\236\211-\353\213\254\353\240\245.py" "b/alstjr7437/\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/\354\271\264\354\236\211-\353\213\254\353\240\245.py" index e69de29b..b368f0c5 100644 --- "a/alstjr7437/\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/\354\271\264\354\236\211-\353\213\254\353\240\245.py" +++ "b/alstjr7437/\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/\354\271\264\354\236\211-\353\213\254\353\240\245.py" @@ -0,0 +1,18 @@ +import sys + +input = sys.stdin.readline + +t = int(input()) + +for _ in range(t): + m, n, x, y = map(int, input().split()) + + k = x # k를 x로 초기화 + result = -1 + while k <= m * n: # k의 범위는 m*n을 넘을 수 없게 + if (k - x) % m == 0 and (k - y) % n == 0: + result = k + break + k += m + + print(result) # 결과값 출력 \ No newline at end of file From 83c6cbd689aa198aa8c2e2dac3b3cf91b203f999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Tue, 11 Jun 2024 16:20:34 +0900 Subject: [PATCH 5/6] =?UTF-8?q?29=EC=B0=A8=EC=8B=9C=20=EB=AC=B8=EC=A0=9C?= =?UTF-8?q?=20=EC=84=A0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alstjr7437/README.md | 1 + ...3\202\230\353\254\264\354\236\220\353\245\264\352\270\260.py" | 0 2 files changed, 1 insertion(+) create mode 100644 "alstjr7437/\354\235\264\353\266\204\355\203\220\354\203\211/\353\202\230\353\254\264\354\236\220\353\245\264\352\270\260.py" diff --git a/alstjr7437/README.md b/alstjr7437/README.md index 5caf5a3a..ec2bdf48 100644 --- a/alstjr7437/README.md +++ b/alstjr7437/README.md @@ -30,3 +30,4 @@ | 26차시 | 2024.05.22 | 정렬 | H-Index | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/196 | | 27차시 | 2024.05.26 | 우선순위 큐 | 이중 우선순위 큐 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/198 | | 28차시 | 2024.05.30 | 브루트 포스 | 카잉 달력 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/203 | +| 29차시 | 2024.06.11 | 이분 탐색 | 나무 자르기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/210 | diff --git "a/alstjr7437/\354\235\264\353\266\204\355\203\220\354\203\211/\353\202\230\353\254\264\354\236\220\353\245\264\352\270\260.py" "b/alstjr7437/\354\235\264\353\266\204\355\203\220\354\203\211/\353\202\230\353\254\264\354\236\220\353\245\264\352\270\260.py" new file mode 100644 index 00000000..e69de29b From 3c1dccfa3adaa633e893b9e6ef7dabd607fa3e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Tue, 11 Jun 2024 23:24:58 +0900 Subject: [PATCH 6/6] =?UTF-8?q?29=EC=B0=A8=EC=8B=9C=20=EB=AC=B8=EC=A0=9C?= =?UTF-8?q?=20solved?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...64\354\236\220\353\245\264\352\270\260.py" | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git "a/alstjr7437/\354\235\264\353\266\204\355\203\220\354\203\211/\353\202\230\353\254\264\354\236\220\353\245\264\352\270\260.py" "b/alstjr7437/\354\235\264\353\266\204\355\203\220\354\203\211/\353\202\230\353\254\264\354\236\220\353\245\264\352\270\260.py" index e69de29b..e8f8f966 100644 --- "a/alstjr7437/\354\235\264\353\266\204\355\203\220\354\203\211/\353\202\230\353\254\264\354\236\220\353\245\264\352\270\260.py" +++ "b/alstjr7437/\354\235\264\353\266\204\355\203\220\354\203\211/\353\202\230\353\254\264\354\236\220\353\245\264\352\270\260.py" @@ -0,0 +1,31 @@ +n, m = map(int, input().split()) +tree = list(map(int, input().split())) + +start = 1 +end = max(tree) + +while start <= end: + mid = (start + end) // 2 + temp = 0 + for i in tree: + if i > mid: + temp += i - mid + + if temp >= m : + start = mid + 1 + else : + end = mid - 1 + +print(end) + +# result = min(tree) +# while True: +# temp = 0 +# for i in tree: +# if i > result : +# temp += i - result +# if temp <= m : +# break +# result += 1 + +# print(result)