Chef and his WBC Career Solution

Problem

Chef has been participating in World's Best Chef (WBC) for 7 years in a row now. Chef calls his WBC career successful if the number of times he has won is strictly greater than the number of times he didn't. WBC takes place annually. Chef's WBC career is described as an array of containing 7 elements. The i^{th} element a_i is 1 if Chef has won in the i^{th} year and 0 otherwise.

Find if Chef's career was successful or not.

Input Format

  • First line of input contains a single integer T, number of testcases. The description of each test case follows.
  • The first and the only line of each test case contains 7 space-separated integers, i^{th} of them is a_i.

Output Format

For each test case print "Yes" (without quotes) if Chef's career was successful and "No" otherwise.

You may print each character of the string in uppercase or lowercase (for example, the strings "yEs""yes""Yes" and "YES" will all be treated as identical).

Constraints

  • 1 \leq T \leq 20
  • a_i \in \{ 0,1\}

Sample 1:

Input
Output
3
1 1 1 1 0 0 0
1 0 1 0 1 0 1
0 1 0 1 0 1 0
YES
YES
NO

Explanation:

  • In the first test case, Chef has won 4 times and lost 3 times. 





Program :


 /* package codechef; // don't place package name! */


import java.util.*;

import java.lang.*;

import java.io.*;


/* Name of the class has to be "Main" only if the class is public. */

class Codechef

{

public static void main (String[] args) throws java.lang.Exception

{

// your code goes here

Scanner sc=new Scanner (System.in);

int t=sc.nextInt();

int n=7,i,j;

int a[]=new int[n];

while(t>0)

{

    t--;

    for(i=0;i<n;i++)

    {

        a[i]=sc.nextInt();

    }

    int count=0;

    int zero=0;

    for(i=0;i<n;i++)

    {

        if(a[i]==1)

        {

            count++;

        }

        else 

        {

            zero++;

        }

    }

     if(count>zero)

        {

            System.out.println("YES");

        }

        else 

        {

            System.out.println("NO");

        }

}

}

}


Post a Comment

0 Comments