You are given length of n sides, you need to answer whether it is possible to make n sided convex polygon with it.
Input
First line contains Tno of testcases.
For each test case , first line consist of single integer N,second line consist of N (l1,l2ln)spaced integers, size of each side.

2
3
4 3 2 
4
1 2 1 4
Output
For each test case print "Yes" if it is possible to make polygon or else "No" if it is not possible.

Yes
No


 Solution

    import java.util.*;
class Polygon{
    public static void main(String[] args) {
  Scanner sc=new Scanner(System.in);
         int t=sc.nextInt();
          while(t-->0)
              {
            int n=sc.nextInt();
            int a[]=new int[n];
            int sum=0;
            for(int i=0;i<n;i++)
            {

               a[i]=sc.nextInt();
            }
            Arrays.sort(a);
            int large=a[n-1];
       for(int i=0;i<n-1;i++) //4 3 2 //1 1 2 4
               {
sum+=a[i]; //9 8
}
if(sum>large)
System.out.println("Yes");
else
 System.out.println("No");
}
}
}
    
    

Post a Comment

Previous Post Next Post