A structural fabrication shop receives a batch of rod-length triples pulled from its inventory scanner. Each triple lists three rod lengths, in millimeters, that a technician wants to weld together into a triangular support bracket. A bracket is only certified for installation when the three rods can be joined edge-to-edge to form an actual, non-degenerate triangle — that is, the sum of any two of the rod lengths must be strictly greater than the third rod length. Given the full batch of candidate triples, certify each one independently.
Line 1: an integer T, the number of rod triples in the batch. Each of the next T lines contains three integers x y z separated by spaces — the three candidate rod lengths for one triple.
Print T lines. For the i-th triple (in the order given), print YES if those three rod lengths can form a valid triangular bracket, or NO otherwise.
Example 1
Input
3 3 4 5 1 1 2 7 10 5
Expected
YES NO YES
Explanation
The first triple 3,4,5 satisfies 3+4>5, 3+5>4, and 4+5>3, so it forms a valid triangle -> YES. The second triple 1,1,2 is degenerate: 1+1 equals 2 rather than exceeding it, so it cannot form a real triangle -> NO. The third triple 7,10,5 satisfies all three strict inequalities (7+10>5, 7+5>10, 10+5>7) -> YES.
Example 2
Input
2 1000000000 1000000000 1000000000 1 2 1000000000
Expected
YES NO
Explanation
The first triple has three equal maximum-length rods; any two of them sum to twice the maximum value, which exceeds the third, so it certifies -> YES. The second triple has two very short rods (1 and 2) summing to only 3, far short of the third rod's length of 1000000000, so it fails the triangle inequality -> NO.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →