PROBLEM 15
Easy

Triangle Existence

Programming Basics · Java

</>
STATUS Not solved

TASK

Problem

#15

Read three positive side lengths. Print `YES` if they can form a non-degenerate triangle, otherwise print `NO`.

EXAMPLE

Example

Input
3 4 5
Output
YES

LIMITS

Constraints

1 ≤ a, b, c ≤ 10^9
📖
LEARN Theory for this problem
+

The core idea of **Triangle Existence** is to model the requested operation directly: Read three positive side lengths. Print `YES` if they can form a non-degenerate triangle, otherwise print `NO`. The reference solution uses `Scanner` for input. Keep only the state needed for this result, choose numeric types that cover the stated bounds, and preserve the exact input/output contract. This makes the solution easier to verify on boundary cases and avoids unrelated work.

💡
NEED HELP? Hints
+

['Follow the statement for **Triangle Existence** literally and identify the smallest state needed to produce its output.', 'The reference solution relies on `Scanner` for input; test the smallest allowed input and one boundary case from the constraints.']

ANSWER Solution
+
// CodeMaster — Triangle Existence
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        boolean ok = a + b > c && a + c > b && b + c > a;
        System.out.println(ok ? "YES" : "NO");
    }
}