We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a6c1efc commit 2c230bdCopy full SHA for 2c230bd
1 file changed
김지호/7주차/260209.py
@@ -0,0 +1,32 @@
1
+# https://www.acmicpc.net/problem/2467
2
+# 용액, 골드5
3
+
4
+import sys
5
+sys.stdin = open("../../../input.txt",'r')
6
7
8
+N = int(input())
9
+numbers = list(map(int,input().split(" ")))
10
11
+left = 0
12
+right = N-1
13
14
+min_abs = abs(numbers[left]+numbers[right])
15
+answers = [numbers[left],numbers[right]]
16
17
+while(left < right):
18
+ sum = numbers[left] + numbers[right]
19
+ if(abs(sum) <= min_abs):
20
+ min_abs = min(min_abs,abs(sum))
21
+ answers = [numbers[left],numbers[right]]
22
23
+ if(sum < 0):
24
+ left += 1
25
+ elif(sum > 0):
26
+ right -= 1
27
+ else:
28
+ break
29
30
+print(" ".join(map(str,answers)))
31
32
0 commit comments