 # CNOTE - Editorial

You’re reading the input in the wrong order: look at the Input section of the Problem statement more carefully 1 Like

T=int(input())
for i in range(T):
X,Y,K,N=map(int,input().split())
p=[]
c=[]
flag=1
for j in range(N):

``````           p,c=map(int,input().split())
if(c<=K and p+Y>=X):
flag=0
if(flag==0):
print('LuckyChef')
else:
print('UnluckyChef')``````
``````	public static void main (String[] args) throws java.lang.Exception
{

String mainInput[];
int no_of_pages_required;
int no_of_pages_left;
int money;
int no_of_notebooks;

String notebook_details[];
int pages;
int price;
boolean flag;
for(int i = 0; i<t; i++) {

flag = true;
//assignment of inputs
no_of_pages_required = Integer.parseInt(mainInput);
no_of_pages_left = Integer.parseInt(mainInput);
money = Integer.parseInt(mainInput);
no_of_notebooks = Integer.parseInt(mainInput);

for(int j = 0; j<no_of_notebooks; j++) {
//assignment of notebook_mdetails
pages = Integer.parseInt(notebook_details);
price = Integer.parseInt(notebook_details);

if(pages >= no_of_pages_required - no_of_pages_left && price <= money) {
System.out.println("LuckyChef");
flag = false;
break;
}
}

if(flag)
System.out.println("UnluckyChef");
}
}
``````

I am getting Runtime error - NZEC in this. Can’t get it to working Same as this guy: CNOTE - Editorial

1 Like

Alright. Checking into it right away.

1 Like

I’ve just edited that post as the testcase contained some extra whitespace that caused your solution to choke, so make sure you’re using the updated testcase to debug 2 Likes

Got it working. I really need to start focusing on the little things. Thanks for the help!

1 Like

``` T = int(input()) for i in range(T): X,Y,K,N = map(int, input().split(’ ‘)) books = [] for k in range(N): p,c = map(int, input().split(’ ')) books.append((p,c)) for p,c in books: if p>=(X-Y) and c<=K: print(‘LuckyChef’) break else: print(‘UnluckyChef’) ```

Figured out the solution myself.
I think there was extra whitespace in test cases…so added `input().strip().split(’ ')` and it is working now!!

1 Like

#include
using namespace std;

int main() {
int i,t,x,y,k,n,p,c,j=0;
cin>>t;
for(int i=0;i<t;i++)
{cin>>x>>y>>k>>n;
bool found=false;
for(int i=0;i<n;i++)
{cin>>p>>c;
if(p>=x-y&&c<=k)
{found=true;
break;
}}
cout<<(found?“LuckyChef”:“UnluckyChef”)<<endl;}
return 0;
}
When i run the program it runs successfully but on submission shows wrong answer.
Can somebody please point out the mistakes.

Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! Edit:

While we’re waiting - make sure your code gets the correct answer for this testcase.

Very well organized and over simplified tutorial ! Exactly what a newbie like me needs ! GREAT WORK!

https://www.codechef.com/viewsolution/37036315
This solution is giving runtime error because of break statement in the if block. Please tell me the reason behind it.

Try with this testcase:

and all should become clear 2 Likes

Thanks @ssjgz 1 Like

#include
using namespace std;

int main() {
long long t,poet,chefpage,chefK,n,pageN,costN;
cin>>t;
while(t–){
bool f=false;
cin>>poet>>chefpage>>chefK>>n;
while(n–){
cin>>pageN>>costN;
if(pageN>=poet-chefpage && costN<=chefK){
f=!f;
break;
}
}
if(f){
cout<<“LuckyChef”<<endl;
}else{
cout<<“UnluckyChef”<<endl;
}
}
return 0;
}

The only difference I see in the array for cost and pages. int P;
int C; how does This give the correct answer please explain if you get to know.

The only difference I see in the array for cost and pages. int P;
int C; how does This give the correct answer please explain if you get to know.

very good editorial.
Thanks author

my python code
t=int(input())

for _ in range(t):

``````x,y,k,n=[int(a) for a in input().split()]

want=x-y

re="UnluckyChef"

for l in range(n):

p,c=[int(a) for a in input().split()]

if p>=want and c<=k:

re="LuckyChef"

print(re)``````