From f7259b3ba2aae9b2d30f69c7fe2602df6ae3b3a5 Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Tue, 22 Apr 2025 00:18:59 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[BOJ]=20#2470.=20=EB=91=90=20=EC=9A=A9?= =?UTF-8?q?=EC=95=A1=20/=20=EA=B3=A8=EB=93=9C5=20/=2030=EB=B6=84=20/=20?= =?UTF-8?q?=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0-\353\221\220\354\232\251\354\225\241.py" | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 "_WeeklyChallenges/W08-[TwoPointer]/2025-04-21-[\353\260\261\354\244\200]-#2470-\353\221\220\354\232\251\354\225\241.py" diff --git "a/_WeeklyChallenges/W08-[TwoPointer]/2025-04-21-[\353\260\261\354\244\200]-#2470-\353\221\220\354\232\251\354\225\241.py" "b/_WeeklyChallenges/W08-[TwoPointer]/2025-04-21-[\353\260\261\354\244\200]-#2470-\353\221\220\354\232\251\354\225\241.py" new file mode 100644 index 00000000..19441b7f --- /dev/null +++ "b/_WeeklyChallenges/W08-[TwoPointer]/2025-04-21-[\353\260\261\354\244\200]-#2470-\353\221\220\354\232\251\354\225\241.py" @@ -0,0 +1,26 @@ +import sys +input = sys.stdin.readline + +N = int(input()) # 전체 용액의 수 +liquid = sorted(map(int, input().split())) + +left = 0 +right = N - 1 + +# 초기값 설정 +answer = abs(liquid[left] + liquid[right]) +answer_liquid = [liquid[left], liquid[right]] + +while left < right: + temp = liquid[left] + liquid[right] + # 합이 0에 더 가까우면 정답 갱신 + if abs(temp) < answer: + answer = abs(temp) + answer_liquid = [liquid[left], liquid[right]] + # 포인터 이동 + if temp < 0: + left += 1 + else: + right -= 1 + +print(answer_liquid[0], answer_liquid[1]) \ No newline at end of file From 35d4a63dd747aef922d6774ef7c999a50d64ba7c Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Wed, 23 Apr 2025 16:34:24 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[BOJ]=20#2473.=20=EC=84=B8=20=EC=9A=A9?= =?UTF-8?q?=EC=95=A1=20/=20=EA=B3=A8=EB=93=9C3=20/=2045=EB=B6=84=20/=20?= =?UTF-8?q?=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 --- ...3-\354\204\270\354\232\251\354\225\241.py" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "minjeong/TwoPointer_SlidingWindow/2025-04-26-[\353\260\261\354\244\200]-#2473-\354\204\270\354\232\251\354\225\241.py" diff --git "a/minjeong/TwoPointer_SlidingWindow/2025-04-26-[\353\260\261\354\244\200]-#2473-\354\204\270\354\232\251\354\225\241.py" "b/minjeong/TwoPointer_SlidingWindow/2025-04-26-[\353\260\261\354\244\200]-#2473-\354\204\270\354\232\251\354\225\241.py" new file mode 100644 index 00000000..4dbd699f --- /dev/null +++ "b/minjeong/TwoPointer_SlidingWindow/2025-04-26-[\353\260\261\354\244\200]-#2473-\354\204\270\354\232\251\354\225\241.py" @@ -0,0 +1,27 @@ +import sys +input = sys.stdin.readline + +N = int(input()) # 전체 용액의 수 +liquid = sorted(map(int, input().split())) + +left = 0 +right = N-1 +mid = (left + right) // 2 +answer = abs(liquid[left] + liquid[mid] + liquid[right]) +answer_liquid = [liquid[left], liquid[mid], liquid[right]] + +for i in range(N-2): + left = i + 1 + right = N - 1 + + while left < right: + temp = liquid[i] + liquid[left] + liquid[right] + if abs(temp) < answer: + answer = abs(temp) + answer_liquid = [liquid[i], liquid[left], liquid[right]] + if temp < 0: + left += 1 + else: + right -= 1 + +print(*answer_liquid) \ No newline at end of file From bfd963efbf82134faa103825e4cbd07924b9bb9d Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Thu, 24 Apr 2025 22:28:02 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[BOJ]=20#5107.=20=EB=A7=88=EB=8B=88?= =?UTF-8?q?=EB=98=90=20/=20=EC=8B=A4=EB=B2=841=20/=2080=EB=B6=84=20/=20?= =?UTF-8?q?=EC=8B=A4=ED=8C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...7-\353\247\210\353\213\210\353\230\220.py" | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 "minjeong/UnionFind/2025-04-26-[\353\260\261\354\244\200]-#5107-\353\247\210\353\213\210\353\230\220.py" diff --git "a/minjeong/UnionFind/2025-04-26-[\353\260\261\354\244\200]-#5107-\353\247\210\353\213\210\353\230\220.py" "b/minjeong/UnionFind/2025-04-26-[\353\260\261\354\244\200]-#5107-\353\247\210\353\213\210\353\230\220.py" new file mode 100644 index 00000000..de2f2540 --- /dev/null +++ "b/minjeong/UnionFind/2025-04-26-[\353\260\261\354\244\200]-#5107-\353\247\210\353\213\210\353\230\220.py" @@ -0,0 +1,46 @@ +import sys + +input = sys.stdin.readline + + +# Find 연산(같은 집합에 속하는지 확인하기 위한 함수) +def find(a): + if a != parent[a]: + parent[a] = find(parent[a]) # 경로 압축 + return parent[a] + + +# Union 연산(두 집합을 합치기 위한 함수) +def union(a, b): + p_a = find(a) + p_b = find(b) + + if p_a > p_b: # 값이 더 작은 쪽을 부모로 설정 + parent[p_a] = p_b + else: + parent[p_b] = p_a + + +tc_num = 0 # 테스트케이스 개수 +while True: + N = int(input()) + parent = [i for i in range(N + 1)] # 초기: 각 원소가 자기 자신을 부모로 가짐 + manito = {} + tc_num += 1 # 테스트케이스 업데이트 + + if N == 0: # 입력 종료 + break + + for _ in range(N): + from_p, to_p = input().split() + # manito에 번호 부여 + if from_p not in manito: + manito[from_p] = len(manito) + 1 + if to_p not in manito: + manito[to_p] = len(manito) + 1 + # 합집합 연산 + union(parent[manito[from_p]], parent[manito[to_p]]) + + parent = set(parent) + + print(tc_num, len(parent) - 1) # 0이 포함되어 있으므로 1 빼주어야 함