Algorithm
problem Link : https://www.codechef.com/problems/AVGPROBLEM
Problem
You are given numbers and .
Determine whether the average of and is strictly greater than or not?
NOTE: Average of and is defined as . For example, average of and is , average of and is .
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of integers and .
Output Format
For each test case, output YES
if average of and is strictly greater than , 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
Sample 1:
5 5 9 6 5 8 6 5 7 6 4 9 8 3 7 2
YES YES NO NO YES
Explanation:
Test case : The average value of and is which is strictly greater than .
Test case : The average value of and is which is strictly greater than .
Test case : The average value of and is which is not strictly greater than .
Test case : The average value of and is which is not strictly greater than .
Test case : The average value of and is which is strictly greater than .
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include<stdio.h>
int main()
{
int t,a,b,c;
float avg;
scanf("%d",&t);
while(t--)
{
scanf("%d %d %d",&a,&b,&c);
avg=(a+b)/2.0;
if(avg>c) printf("YES\n");
else printf("NO\n");
}
}
Copy The Code &
Try With Live Editor
Input
5 9 6
5 8 6
5 7 6
4 9 8
3 7 2
Output
YES
NO
NO
YES
Demonstration
CodeChef solution AVGPROBLEM Greater Average CodeChef solution in C,C++