Can someone help me

I was trying to solve this problem=lunchtime|TANDJ1

This is what I did can someone please tell me what I was doing wrong

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

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	   int a,b,x,y,k;
	   cin>>a>>b>>x>>y>>k;
	   int reqs = abs(x-a)+abs(y-b);
	   if(k < reqs){
	       cout<<"NO"<<endl;
	       break;
	   }
	   else if(k == reqs){
	       cout<<"YES"<<endl;
	   }
	   else{
	       int left = k-reqs;
	       if(left % 2 == 0){
	           cout<<"YES"<<endl;
	       }
	       else{
	           cout<<"NO"<<endl;
	       }
	   }
	}
	return 0;
}

.

1 Like

Consider the test input:

2
1 1 10 10 1
1 1 10 10 1

bro I think you should use long long .Your code logic is perfectly right .Also do not use break in if else unessaarly …

Error is coming in break remove it and also use long long .Then you will get AC

You shouldn’t use ‘break’ as it might exit out of the testcase!

1 Like

yes correct both break and overflow might result in a WA

thanks. I didn’t even notice that I used the break in if