We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f7259b3 commit 35d4a63Copy full SHA for 35d4a63
minjeong/TwoPointer_SlidingWindow/2025-04-26-[백준]-#2473-세용액.py
@@ -0,0 +1,27 @@
1
+import sys
2
+input = sys.stdin.readline
3
+
4
+N = int(input()) # 전체 용액의 수
5
+liquid = sorted(map(int, input().split()))
6
7
+left = 0
8
+right = N-1
9
+mid = (left + right) // 2
10
+answer = abs(liquid[left] + liquid[mid] + liquid[right])
11
+answer_liquid = [liquid[left], liquid[mid], liquid[right]]
12
13
+for i in range(N-2):
14
+ left = i + 1
15
+ right = N - 1
16
17
+ while left < right:
18
+ temp = liquid[i] + liquid[left] + liquid[right]
19
+ if abs(temp) < answer:
20
+ answer = abs(temp)
21
+ answer_liquid = [liquid[i], liquid[left], liquid[right]]
22
+ if temp < 0:
23
+ left += 1
24
+ else:
25
+ right -= 1
26
27
+print(*answer_liquid)
0 commit comments