Why is this code not working, is their a logic error?

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define map map<ll, ll>
#define vect vector

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t,n,c,x,y,k,p;
cin>>t;
while(t–){
ll f=0;
cin>>x>>y>>k>>n;
x=x-y;
for (ll i = 0; i < n; i++) {
cin>>p>>c;
if(p>=x && k>=c){
f=1;
break;
}
}

    if(f==0){
        cout<<"UnluckyChef"<<endl;
    }else{
        cout<<"LuckyChef"<<endl;
    }
}

return 0;	

}

thanks ! got it

1 Like

The break statement is the undoing.As soon as you find a suitable book, you break thus not taking all inputs which then proceed to be considered as inputs in the nest testcases.Just remove the break statement and it will be fine.