题解 | #最大乘积#
最大乘积
https://www.nowcoder.com/practice/5f29c72b1ae14d92b9c3fa03a037ac5f?tpId=158&tqId=34013&rp=1&ru=/ta/exam-pdd&qru=/ta/exam-pdd&difficulty=&judgeStatus=&tags=/question-ranking
import sys leng = int(sys.stdin.readline()) a1=0 a2=0 a3=0 b1=0 b2=0 b3=0 l= [] arr = sys.stdin.readline().split() # print(leng,arr) for i in arr: if int(i)>0: if int(i)**2 >a1**2: a3=a2 a2=a1 a1=int(i) elif int(i)**2 >a2**2: a3=a2 a2=int(i) elif int(i)**2 >a3**2: a3=int(i) if int(i)<0: if int(i)**2 >b1**2: b3=b2 b2=b1 b1=int(i) elif int(i)**2 >b2**2: b3=b2 b2=int(i) elif int(i)**2 >b3**2: b3=int(i) # print(a1,a2,a3,l) m1 = a1*a2*a3 m2=b1*b2*a1 if m1>m2: print(m1) else: print(m2)