From 9687cac77b1f894c46c7a7fed62fdb36f8c00c2b Mon Sep 17 00:00:00 2001 From: gwcat0506 <61350052+gwcat0506@users.noreply.github.com> Date: Sat, 20 May 2023 11:39:51 +0900 Subject: [PATCH] =?UTF-8?q?B2470:=20=EB=91=90=20=EC=9A=A9=EC=95=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Baekjoon/gwcat0506/B2470.py | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Baekjoon/gwcat0506/B2470.py diff --git a/Baekjoon/gwcat0506/B2470.py b/Baekjoon/gwcat0506/B2470.py new file mode 100644 index 0000000..81a6a09 --- /dev/null +++ b/Baekjoon/gwcat0506/B2470.py @@ -0,0 +1,38 @@ +import sys + +N = int(sys.stdin.readline()) +N_list = list(map(int,sys.stdin.readline().split())) + +# 이진 탐색을 위한 sort +N_list.sort() + +p1 = 0 +p2 = len(N_list)-1 + +# 모두 산성 용액으로 이뤄졌을 경우 +if N_list[0]>=0 and N_list[1]>=0: + print(N_list[0],N_list[1]) +# 모두 알칼리성 용액만으로 이뤄졌을 경우 +elif N_list[-1]<=0 and N_list[-2]<=0: + print(N_list[-2],N_list[-1]) + +else: + # 가장 큰 수 넣어주면서 초기화 + result = [N_list[p1],N_list[p2],abs(N_list[p1]+N_list[p2])] + + while p1