Chef and his WBC Career: CHEFWBC
Chef and his WBC Career Codechef solution
CU Submission link: Click here (need login by CU account)
Chef has been participating in World’s Best Chef (WBC) for 77 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 77 elements. The ithith element aiai is 11 if Chef has won in the ithith year and 00 otherwise.
Find if Chef’s career was successful or not.
Input Format
- First line of input contains a single integer TT, number of testcases. The description of each test case follows.
- The first and the only line of each test case contains 77 space-separated integers, ithith of them is aiai.
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≤T≤201≤T≤20
- ai∈{0,1}ai∈{0,1}
Sample Input 1
3
1 1 1 1 0 0 0
1 0 1 0 1 0 1
0 1 0 1 0 1 0
Sample Output 1
YES
YES
NO
Explanation
- In the first test case, Chef has won 44 times and lost 33 times
Chef and his WBC Career Codechef solution in C
// copy from here and paste just below the header files
int main()
{
// your code goes here
int t,a[7];
scanf("%d",&t);
while(t--)
{
int sum=0;
for(int i=0; i < 7; i++) {
scanf("%d",&a[i]);
sum=sum+a[i];
}
if (sum > 3)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
Chef and his WBC Career Codechef solution in C++ 17
// include your header files
// copy from here
int main()
{
int t,a[7];
cin>>t;
while(t--) {
int sum=0;
for(int i=0; i < 7; i++) {
cin>> a[i];
sum=sum+a[i];
}
if (sum > 3)
cout<< "YES" << endl;
else
cout<< "NO" << endl;
}
return 0;
}
Chef and his WBC Career Codechef solution in Java
/* 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
int[] a = new int[10];
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int sum=0;
for(int i=0; i < 7; i++) {
a[i]=sc.nextInt();
sum=sum+a[i];
}
if (sum > 3)
System.out.println("Yes");
else
System.out.println("No");
}
}
}