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 , i.e, problems whose difficulty is at least and at most .
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 YES
, yEs
, and Yes
will be considered identical.
Constraints
Sample 1:
5 1300 1500 1201 1402 300 4000 723 805 1330 512
YES NO NO YES NO
Explanation:
Test case : Chef's current rating is , so he should solve problems with difficulty lying in . Since lies in , Chef is doing his practice in a recommended way :)
Test case : Chef's current rating is , so he should solve problems with difficulty lying in . Since does not lie in , Chef is not doing his practice in a recommended way :(
Test case : Chef's current rating is , so he should solve problems with difficulty lying in . Since does not lie in , Chef is not doing his practice in a recommended way :(
Test case : Chef's current rating is , so he should solve problems with difficulty lying in . Since lies in , Chef is doing his practice in a recommended way :)
Test case : Chef's current rating is , so he should solve problems with difficulty lying in . Since does not lie in , 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
1300 1500
1201 1402
300 4000
723 805
1330 512
Output
NO
NO
YES
NO
Demonstration
CodeChef solution ADVANCE - Rating Improvement solution in Codechef solution in C,C++