# Help me in solving AGELIMIT problem

### My code

``````# cook your dish here
n=int(input())
for i in range(n):
x,y,a = map(int,input().split())
if a>=x and a<y:
print("YES")
elif a>=x and a>y:
print("NO")
elif a<=x and a>y:
print("NO")
elif a>=x and x<y:
print("YES")
else:
print("NO")
``````

Problem Link: AGELIMIT Problem - CodeChef

In C language I solved this program. If you find this useful kindly go through it.I have taken 4 inputs t for testcase ,x and y for maximum and minimum age and a for chef’s age.In if condition I used x>= and y< a is the given condition is met the answer is true else false.
include <stdio.h>

int main(void) {
int x,y,a,t;
scanf(“%d “,&t);
for(int i=0;i<t;i++){
scanf(”%d %d %d”,&x,&y,&a);
if(a>=x && a<y)
{
printf(“YES\n”);
}
else
{
printf(“NO\n”);
}}
return 0;
}

Here how I solved the problem in the java,
// To read from the console
Scanner sc=new Scanner(System.in);
//to iterate through inputs
int t=sc.nextInt();
for(int i=0;i<t;i++){
int x=sc.nextInt();
int y=sc.nextInt();
int a=sc.nextInt();
if(a>=x && a<y){
System.out.println(“YES”);
}else System.out.println(“NO”);
}

Do let me know if you need the explanation

@satya_praveen - do you really need the following in your code?

``````    elif a>=x and a>y:
print("NO")
elif a<=x and a>y:
print("NO")
elif a>=x and x<y:
print("YES")
``````

The following is sufficient right?

``````if a>=x and a<y:
print("YES")
else:
print("NO")
``````
1 Like