Question: Creating Polygon Problem Statement: Polygon: A polygon is a closed plane figure composed of three or more line segments in which its longest side is

Creating Polygon
Problem Statement: Polygon: A polygon is a closed plane figure composed of three or more line segments in which its longest side is smaller than the sum of its other sides. You are given an array of size n named sides. Find the polygon with the largest perimeter that can be formed from the given sides and print the perimeter of the same.
Note:
The Array will not be empty.
Each element of the array>=0
If a polygon cannot be formed from the given sides, then print -1
Input Format:
The input consists of two lines:
The first line consists of a single integer denoting n..
The second line corisists of n space-separated integers denoting the array sides
The input will be read from the STDIN by the candidate
Output Format:
The output will be matched to the candidate's output printed on the STDOUT
Print the perimeter of the polygon otherwise print-1
Constraints:
0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!