#P10245. Constructing a Trapezoidal Swimming Pool

    ID: 12242 Type: Default 1000ms 256MiB

Constructing a Trapezoidal Swimming Pool

Constructing a Trapezoidal Swimming Pool

Little J wants to build a quadrilateral swimming pool ABCD such that one pair of opposite sides is parallel (to facilitate family competitions) while the other pair is not parallel (to add a touch of uniqueness). In other words, the pool must be a trapezoid (i.e. only one pair of opposite sides is parallel).

You are given four positive integers \(p,q,r,s\) representing the side lengths \(AB=p,\; BC=q,\; CD=r,\; DA=s\). Determine if it is possible to construct a trapezoid with these side lengths. In this problem, a quadrilateral is a trapezoid if one pair of opposite sides is parallel and the other pair is not. That is, if either:

  • \(AB \parallel CD\) with \(p \neq r\) and the trapezoid (with bases \(p\) and \(r\) and legs \(q\) and \(s\)) is non-degenerate, or
  • \(BC \parallel AD\) with \(q \neq s\) and the trapezoid (with bases \(q\) and \(s\) and legs \(r\) and \(p\)) is non-degenerate.

A necessary (but not sufficient) condition for a convex quadrilateral to exist is that each side is less than the sum of the other three. For the trapezoid with bases \(a\) and \(c\) and legs \(b\) and \(d\) (with \(a\neq c\)), one can show that a non‐degenerate trapezoid exists if and only if \[ 4(a-c)^2 b^2 > \Bigl[(a-c)^2 + b^2 - d^2\Bigr]^2, \] and a similar condition holds for the configuration with the other pair as parallel.

inputFormat

The input consists of one line containing four positive integers \(p, q, r, s\) separated by spaces.

outputFormat

Output a single line: YES if it is possible to construct a trapezoidal swimming pool using the given side lengths, or NO otherwise.

sample

3 4 5 6
NO