From d0f2f27a89bb7dd8b9130127d08325d573e6a27f Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Thu, 23 Oct 2025 20:03:48 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[BOJ]=20#10025.=20=EA=B2=8C=EC=9C=BC?= =?UTF-8?q?=EB=A5=B8=20=EB=B0=B1=EA=B3=B0=20/=20=EC=8B=A4=EB=B2=843=20/=20?= =?UTF-8?q?50=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 --- ...74\353\245\270\353\260\261\352\263\260.py" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "minjeong/TwoPointer_SlidingWindow/2025-10-23-[\353\260\261\354\244\200]-#10025-\352\262\214\354\234\274\353\245\270\353\260\261\352\263\260.py" diff --git "a/minjeong/TwoPointer_SlidingWindow/2025-10-23-[\353\260\261\354\244\200]-#10025-\352\262\214\354\234\274\353\245\270\353\260\261\352\263\260.py" "b/minjeong/TwoPointer_SlidingWindow/2025-10-23-[\353\260\261\354\244\200]-#10025-\352\262\214\354\234\274\353\245\270\353\260\261\352\263\260.py" new file mode 100644 index 0000000..1871ce5 --- /dev/null +++ "b/minjeong/TwoPointer_SlidingWindow/2025-10-23-[\353\260\261\354\244\200]-#10025-\352\262\214\354\234\274\353\245\270\353\260\261\352\263\260.py" @@ -0,0 +1,25 @@ +import sys +input = sys.stdin.readline + +# N: 얼음 양동이 수, K: 떨어진 거리 +N, K = map(int, input().split()) +buckets = [] +max_x = 0 +for _ in range(N): + # g: 얼음 양, x: 양동이 좌표 + g, x = map(int, input().split()) + buckets.append((g, x)) + max_x = max(max_x, x) + +arr = [0] * (max_x+1) +for g, x in buckets: + arr[x] += g + +window_size = 2 * K + 1 +current = sum(arr[:window_size]) +answer = current +for i in range(window_size, max_x + 1): + current += arr[i] - arr[i - window_size] + answer = max(answer, current) + +print(answer) \ No newline at end of file From 62e726fced78d65a7709a2ba758477b842bf234f Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Sat, 25 Oct 2025 20:04:53 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[BOJ]=20#3151.=20=ED=95=A9=EC=9D=B4=200=20/?= =?UTF-8?q?=20=EA=B3=A8=EB=93=9C4=20/=201=EC=8B=9C=EA=B0=84=20/=EC=8B=A4?= =?UTF-8?q?=ED=8C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\200]-#3151-\355\225\251\354\235\2640.py" | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 "minjeong/TwoPointer_SlidingWindow/2025-10-25-[\353\260\261\354\244\200]-#3151-\355\225\251\354\235\2640.py" diff --git "a/minjeong/TwoPointer_SlidingWindow/2025-10-25-[\353\260\261\354\244\200]-#3151-\355\225\251\354\235\2640.py" "b/minjeong/TwoPointer_SlidingWindow/2025-10-25-[\353\260\261\354\244\200]-#3151-\355\225\251\354\235\2640.py" new file mode 100644 index 0000000..5c3ccd6 --- /dev/null +++ "b/minjeong/TwoPointer_SlidingWindow/2025-10-25-[\353\260\261\354\244\200]-#3151-\355\225\251\354\235\2640.py" @@ -0,0 +1,53 @@ +import sys +input = sys.stdin.readline + +N = int(input()) +coding = list(map(int, input().split())) +coding.sort() +answer = 0 + +for i in range(N): + target = -coding[i] + left = i + 1 + right = N - 1 + + while left < right: + two_sum = coding[left] + coding[right] + if two_sum < target: + left += 1 + elif two_sum > target: + right -= 1 + else: # two_sum == target + if coding[left] != coding[right]: + left_value = coding[left] + right_value = coding[right] + + # 왼쪽에 같은 값(left_value)이 연속으로 몇 명 있는지 센다 + cnt_left = 1 + while left + cnt_left < right and coding[left + cnt_left] == left_value: + cnt_left += 1 + + # 오른쪽에 같은 값(right_value)이 연속으로 몇 명 있는지 센다 + cnt_right = 1 + while right - cnt_right > left and coding[right - cnt_right] == right_value: + cnt_right += 1 + + # 이 조합들 각각은 전부 서로 다른 학생 조합이므로 + # 경우의 수 = cnt_left * cnt_right + answer += cnt_left * cnt_right + + # 세야 할 학생을 처리했으므로, 포인터 한 번에 이동 + left += cnt_left + right -= cnt_right + + else: # coding[left] == coding[right] + # 이 구간에 남은 학생 수 + m = right - left + 1 + + # m명 중 2명을 뽑는 조합 수 C(m, 2) + answer += m * (m - 1) // 2 + + # i에 대해 셀 조합 종료 + break + +print(answer)