# Help me in solving CNOTE problem

### My issue

include
using namespace std;

int main() {
int x,y,n,k,t;
bool flag;
//vector price;
cin>>t;
while(t–) {
cin>>x>>y>>k>>n;
int a,b;
flag = false;
for(int i=0; i< n; i++)
{
cin>>a>>b;
if((x-y) <= a && b <= k)
{
cout<<“LuckyChef\n”;
flag = true;
break;
}
}
if(!flag)
cout<<“UnluckyChef\n”;
}
return 0;
}

Bro wtf why is it wrong ???

### My code

``````#include <iostream>
using namespace std;

int main() {
int x,y,n,k,t;
bool flag;
//vector<int> price;
cin>>t;
while(t--) {
cin>>x>>y>>k>>n;
int a,b;
flag = false;
for(int i=0; i< n; i++)
{
cin>>a>>b;
if((x-y) <= a && b <= k)
{
cout<<"LuckyChef\n";
flag = true;
break;
}
}
if(!flag)
cout<<"UnluckyChef\n";
}
return 0;
}

``````

Problem Link: CNOTE Problem - CodeChef

@m1tul5
Just a simple mistake .
When u get an answer in the middle of the loop .
U will ignore rest inputs of the a,b and break the loop.
Which is wrong .
I have changed your code a bit to handle it.

``````#include <iostream>
using namespace std;

int main() {
int x,y,n,k,t;
bool flag;
//vector<int> price;
cin>>t;
while(t--) {
cin>>x>>y>>k>>n;
int a,b;
flag = false;
for(int i=0; i< n; i++)
{
cin>>a>>b;
if((x-y) <= a && b <= k)
{

flag = true;
}
}
if(!flag)
cout<<"UnluckyChef\n";
else
cout<<"LuckyChef\n";
}
return 0;
}
``````