Algorithm
Problem Link - https://www.codechef.com/START42A/problems/AGELIMIT
Problem
Chef wants to appear in a competitive exam. To take the exam, there are following requirements:
- Minimum age limit is (i.e. Age should be greater than or equal to ).
- Age should be strictly less than .
Chef's current Age is . Find whether he is currently eligible to take the exam or not.
Input Format
- First line will contain , number of test cases. Then the test cases follow.
- Each test case consists of a single line of input, containing three integers and as mentioned in the statement.
Output Format
For each test case, output YES
if Chef is eligible to give the exam, 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 21 34 30 25 31 31 22 29 25 20 40 15 28 29 28
YES NO YES NO YES
Explanation:
Test case : The age of Chef is . His age satisfies the minimum age limit as . Also, it is less than the upper limit as . Thus, Chef is eligible to take the exam.
Test case : The age of Chef is . His age satisfies the minimum age limit as . But, it is not less than the upper limit as . Thus, Chef is not eligible to take the exam.
Test case : The age of Chef is . His age satisfies the minimum age limit as . Also, it is less than the upper limit as . Thus, Chef is eligible to take the exam.
Test case : The age of Chef is . His age does not satisfy the minimum age limit as . Thus, Chef is not eligible to take the exam.
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include<stdio.h>
int main()
{
int t, x, y, a;
scanf("%d", &t);
while(t--)
{
scanf("%d %d %d", &x, &y, &a);
if(a >= x && a > y) printf("YES\n");
else printf("NO\n");
}
}
Copy The Code &
Try With Live Editor
Input
21 34 30
25 31 31
22 29 25
20 40 15
28 29 28
Output
NO
YES
NO
YES
Demonstration
CodeChef solution AGELIMIT - Age Limit Codechef solution in C, C++, Java