Editorial for DMOPC '19 Contest 6 P0 - Trivial Math


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

Author: Tzak

Consider the case in which the sum of lengths of the two shorter sides is less than or equal to the length of the longest side. The shorter sides will either not be able to span across the width of the longest side or will touch to form a triangle with an area of 0. Therefore, no triangle with non-zero area can be produced.

Otherwise, it is always possible to produce a triangle with non-zero area.

Pseudocode:

read a, b, c
sides = sorted([a, b, c])
if sides[0] + sides[1] <= sides[2]
    print "no"
else
    print "yes"

Time complexity: \mathcal O(1)


Comments

There are no comments at the moment.