You are viewing a single comment's thread. Return to all comments →
Passed 13/13 testcase
def check1(e): return e[3] def check2(p,d,flag,count): for i in p: if d==i[3]: count+=1 if count==1: return True elif count>1: return False p=[] n=int(input()) data=input().split(" ") data=[int(i) for i in data] for i in range(n-2): j,k=i+1,i+2 if data[i]+data[j]>data[k] and data[i]+data[k]>data[j] and data[j]+data[k]>data[i]: p.append([data[i],data[j],data[k],data[i]+data[j]+data[k]]) if len(p)<=1: if len(p)==0: print(-1) else: print(f'{p[0][0]} {p[0][1]} {p[0][2]}') else: p.sort(reverse=True,key=check1) flag=check2(p,p[0][3],True,0) if flag==True: print(f'{p[0][0]} {p[0][1]} {p[0][2]}') else: count=0 flag=check2(p,p[-1][3],True,0) if flag==True or flag==False: print(f'{p[-1][0]} {p[-1][1]} {p[-1][2]}')
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Perimeter Triangle
You are viewing a single comment's thread. Return to all comments →
Passed 13/13 testcase