Hi everyone,
This is my code. It is an easy one but I am still getting a java.util.NoSuchElementException.
Not only for this code, but for various others. It is running successfully on Eclipse IDE.
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
static String printAns(int x,int y,int k,int n,int arr[])
{
int left = x-y;
for(int i = 1;i<arr.length;i+=2)
{
if(arr[i] <= k)
{
if(arr[i-1] >= left)
return “LuckyChef”;
}
}
return “UnluckyChef”;
}
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t>0)
{
int x = sc.nextInt();
int y = sc.nextInt();
int k = sc.nextInt();
int n = sc.nextInt();
int arr[] = new int[n*2];
for(int i = 0;i<arr.length;i++)
{
arr[i] = sc.nextInt();
}
System.out.println(printAns(x,y,k,n,arr));
t--;
}
}
}