Greater Average Codechef Solution

Hello coders, today we are going to solve the Greater Average Codechef Solution whose Problem Code is AVGPROBLEM.

As you already know that this site does not contain only the Codefchef solutions here, you can also find the solution for other programming problems. I.e. LeetcodeC programsC++ Programs SolutionsPython ProgramsWeb Technology, Data StructuresRDBMS Programs and Java Programs Solutions.

Greater Average Codechef Solution
Greater Average Codechef Solution

Greater Average Codechef Solution

Problem

You are given 33 numbers A, B, and C.

Determine whether the average of A and B is strictly greater than C or not?

NOTE: Average of A and B is defined as (A+B)/2. For example, average of 5 and 9 is 7, average of 5 and 8 is 6.5.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of 3 integers A, B, and C.

Output Format

For each test case, output YES if average of A and B is strictly greater than C , NO otherwise.

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

Constraints

  • 1 ≤ T ≤ 10
    1 ≤ A , B , C ≤ 10

Sample 1

Input

5
5 9 6
5 8 6
5 7 6
4 9 8
3 7 2

YES
YES
NO
NO
YES

LinkedIn Skill Assessment Answers

Coursera Quiz Answers

Explanation:

Test case 1: The average value of 5 and 9 is 7 which is strictly greater than 6.

Test case 2: The average value of 5 and 8 is 6.5 which is strictly greater than 6.

Test case 3: The average value of 5 and 7 is 6 which is not strictly greater than 6.

Test case 4: The average value of 4 and 9 is 6.5 which is not strictly greater than 8.

Test case 5: The average value of 3 and 7 is 5 which is strictly greater than 2.

Greater Average Codechef Solution in CPP

#include <iostream>
using namespace std;
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	    float a,b,c;
	    cin>>a>>b>>c;
	    if((a+b)/2>c)
	    {
	        cout<<"YES"<<endl;
	    }
	    else
	    {
	        cout<<"NO"<<endl;
	    }
	}
	return 0;
}
       

Greater Average 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
		Scanner scn = new Scanner(System.in);
		int testCases = scn.nextInt();
		while(testCases-->0){
		    double A = scn.nextInt();
		    double B = scn.nextInt();
		    double C = scn.nextInt();
		    double average = (A+B)/2;
		    if(average > C){
		        System.out.println("YES");
		    }else{
		        System.out.println("NO");
		    }
		}
	}
}

Greater Average Codechef Solution in Python

# cook your dish here
t=int(input())
for tc in range(t):
    (a,b,c)=map(int,input().split(' '))
    if (a+b)/2>c:
        print('YES')
    else:
        print('NO')
    

Disclaimer: The above Problem (Greater Average ) is generated by CodeChef but the solution is provided by  Chase2learn.This tutorial is only for Educational and Learning purpose.

Finally, we are now, in the end, I just want to conclude some important message for you

Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.

Please share our posts on social media platforms and also suggest to your friends to Join Our Groups. Don’t forget to subscribe. 

Leave a Comment