Polygon
InterviewTime limit1sMemory limit128 MB
Decide whether N given segment lengths can form the sides of some convex polygon, which reduces to checking that the largest length is smaller than the sum of the rest.
Problem
You are given the lengths of segments. Determine whether all of these segments can be arranged, in some order, as the sides of a convex polygon.
In this problem a polygon is considered convex if every interior angle is strictly greater than degrees and strictly less than degrees; equivalently, no three consecutive vertices are collinear.
Input
The first line contains an integer , the number of sides of the polygon (). Each of the following lines contains an integer , the length of one side ().
Output
Print YES if a convex polygon can be built using every one of the segments exactly once, in any order, as its sides. Otherwise, print NO SOLUTION.
Hint
