Create a triangle#8372

Create a triangle (Editorial)

Let , and be the lengths of three segments. These segments can form a non-degenerate triangle if the sum of the lengths of any two segments is greater than the length of the third segment. This condition is known as the triangle inequality:

a < b + c~\&\&~b < a + c~\&\&~c < a + b

Algorithm implementation

Read the input data.

scanf("%d %d %d",&a,&b,&c);

Check the triangle inequality and print the answer.

if (a < b + c && b < a + c && c < a + b) 
  printf("YES\n"); 
else
  printf("NO\n");

Java implementation

import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner con = new Scanner(System.in);
    int a = con.nextInt();
    int b = con.nextInt();
    int c = con.nextInt();
    
    if (a < b + c && b < a + c && c < a + b) 
    	System.out.println("YES");
    else
      System.out.println("NO");
    con.close();
  }
}   

Python implementation

Read the input data.

a, b, c = map(int, input().split())

Check the triangle inequality and print the answer.

if a < b + c and b < a + c and c < a + b:
  print("YES\n")
else:
  print("NO\n")