Skip to content

Commit

Permalink
baekjoon/python/gold5/q2470_two_solution.py(두용액)
Browse files Browse the repository at this point in the history
  • Loading branch information
bong6981 committed Apr 9, 2022
1 parent 31a4206 commit 81253a4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions baekjoon/python/gold5/q2470_two_solution.py
@@ -0,0 +1,26 @@
## https://www.acmicpc.net/problem/2470
import sys
input = sys.stdin.readline
n = int(input())
all = sorted(map(int, input().split()))

def sol():
max_v = 2000000000
ans = (-1, -1)
i = 0
j = n - 1
while i < j:
mix = all[i] + all[j]
if mix == 0:
return (i, j)
if abs(mix) < max_v:
max_v = abs(mix)
ans = (i, j)
if mix < 0:
i += 1
else:
j -= 1
return ans

ans = sol()
print(all[ans[0]], all[ans[1]])

0 comments on commit 81253a4

Please sign in to comment.