Algorithm


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

Problem

Chef's current rating is , and he wants to improve it. It is generally recommended that a person with rating  should solve problems whose difficulty lies in the range [�,�+200], i.e, problems whose difficulty is at least  and at most �+200.

You find out that Chef is currently solving problems with a difficulty of .

Is Chef following the recommended practice or not?

Input Format

  • The first line of input will contain a single integer , denoting the number of test cases. The description of the test cases follows.
  • Each test case consists of a single line of input, containing two space-separated integers �,�.

Output Format

For each test case, output on a new line YES if Chef is following the recommended practice style, and NO otherwise.

Each letter of the output may be printed in either lowercase or uppercase. For example, the strings YESyEs, and Yes will be considered identical.

Constraints

  • 1≤�≤100
  • 1≤�,�≤4000

Sample 1:

Input
 
Output
 
5
1300 1500
1201 1402
300 4000
723 805
1330 512
YES
NO
NO
YES
NO

Explanation:

Test case 1: Chef's current rating is 1300, so he should solve problems with difficulty lying in [1300,1500]. Since 1500 lies in [1300,1500], Chef is doing his practice in a recommended way :)

Test case 2: Chef's current rating is 1201, so he should solve problems with difficulty lying in [1201,1401]. Since 1402 does not lie in [1201,1401], Chef is not doing his practice in a recommended way :(

Test case 3: Chef's current rating is 300, so he should solve problems with difficulty lying in [300,500]. Since 4000 does not lie in [300,500], Chef is not doing his practice in a recommended way :(

Test case 4: Chef's current rating is 723, so he should solve problems with difficulty lying in [723,923]. Since 805 lies in [723,923], Chef is doing his practice in a recommended way :)

Test case 5: Chef's current rating is 1330, so he should solve problems with difficulty lying in [1330,1530]. Since 512 does not lie in [1330,1530], Chef is not doing his

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-x < =200 && y>=x) printf("YES\n");
        else printf("No\n");
    }
} 
Copy The Code & Try With Live Editor

Input

x
+
cmd
5
1300 1500
1201 1402
300 4000
723 805
1330 512

Output

x
+
cmd
YES
NO
NO
YES
NO
Advertisements

Demonstration


CodeChef solution ADVANCE  - Rating Improvement solution in Codechef solution in C,C++

Previous
CodeChef solution SIXFRIENDS - Six Friends solution in C,C++
Next
CodeChef solution INSTAGRAM - Instagram CodeChef solution in C, C++