You are viewing a single comment's thread. Return to all comments →
There's no need to complicate it, here's a simple Python solution :
n = int(input())
A = sorted(int(i) for i in input().split())
i = n-3
while i >= 0 and (A[i] + A[i+1] <= A[i+2]) :
i -= 1
if i >= 0 :
Logic : Select the longest possible side such that it can form a non-degenerate triangle using the two sides "just smaller" than it.
It fulfills all other conditions. If no such selection is possible, then no non-degenerate triangle exists.
Informative Tweets for Inquisitive Minds