Algorithm


problem Link : https://www.codechef.com/problems/EXPERT 

Problem

A problem setter is called an expert if at least 50% of their problems are approved by Chef.

Munchy submitted  problems for approval. If  problems out of those were approved, find whether Munchy is an expert or not.

Input Format

  • The first line of input will contain a single integer , denoting the number of test cases.
  • Each test case consists of a two space-separated integers  and  - the number of problems submitted and the number of problems that were approved by Chef.

Output Format

For each test case, output on a new line YES, if Munchy is an expert. Otherwise, print NO.

The output is case-insensitive. Thus, the strings YESyesyeS, and Yes are all considered the same.

Constraints

  • 1≤�≤1000
  • 1≤�≤�≤106

Sample 1:

Input
 
Output
 
4
5 3
1 1
4 1
2 1
YES
YES
NO
YES

Explanation:

Test case 1: We are given that 3 out of 5 problems were approved. Thus, 60% of the problems were approved. Since at least 50% of the problems were approved, Munchy is an expert.

Test case 2: We are given that 1 out of 1 problems were approved. Thus, 100% of the problems were approved. Since at least 50% of the problems were approved, Munchy is an expert.

Test case 3: We are given that 1 out of 4 problems were approved. Thus, 25% of the problems were approved. Since at least 50% of the problems were not approved, Munchy is not an expert.

Test case 4: We are given that 1 out of 2 problems were approved. Thus, 50% of the problems were approved. Since at least 50% of the problems were approved, Munchy is an expert.

Code Examples

#1 Code Example with C Programming

Code - C Programming

#include<stdio.h>
int main()
{
    int t,x,y;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d",&x,&y);
        if(((y*100)/x)>=50) printf("YES\n");
        else printf("No\n");
    }
} 
Copy The Code & Try With Live Editor

Input

x
+
cmd
4
5 3
1 1
4 1
2 1

Output

x
+
cmd
YES
YES
NO
YES
Advertisements

Demonstration


CodeChef solution  EXPERT  - Expert Setter Codechef solution in Codechef solution in C,C++

Previous
CodeChef solution TESTAVG - Test Averages CodeChef solution in Codechef solution in C,C++
Next
CodeChef solution SUGERCANE Sugarcane Juice Business CodeChef solution in C,C++