https://www.acmicpc.net/problem/2467

코드만 보면 간단한 문제인데 꽤 걸렸다.
인덱스 투포인터를 이용하여 low, high를 옮겨주면서 풀면 된다.
만약 l[low] + l[high] 의 절댓값이 원래 저장되어있던 차이보다 작으면 갱신, 0이라면 끝판왕이므로 break를 넣어주었다.
또한 절댓값이 0보다 크면 양수가 더 크다는 의미이므로 high -= 1,
0보다 작으면 음수가 더 크다는 의미이므로 low += 1을 해주었다.
import sys
input = sys.stdin.readline
n = int(input())
l = list(map(int, input().split()))
diff = float('inf') # 0과 차이
x, y = 0, 0
low, high = 0, n-1 # idx
while low < high:
temp = l[low]+l[high]
if abs(temp) < diff:
diff = abs(temp)
x, y = l[low], l[high]
if diff == 0:
break
if temp > 0:
high -= 1
else:
low += 1
print(x, y)