Whats wrong in my code?

Q: https://www.codechef.com/problems/FRUITS

It’s giving WA for some unknown testcase! (XD)

#include
using namespace std;

int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

int T,N,M,K,diff,result;
cin>>T;
while(T--)
{
    cin>>N>>M>>K;
    
    diff=(N>=M)?N-M:M-N;
  //  cout<<diff<<endl;
    
    if(K>=diff)
    {
        result=((K-diff)%2==0)?0:1;
    }
    else
    {
        
        result=(((N>=M)?N:M)-(K+((N>=M)?M:N)));
        
    }
cout<<result<<endl;
    
}    

return 0;

}

You should not just paste your code here. Instead share the link to your solution. Also post the question it refers to.

1 Like

Everything is correct, since there is no question and no syntax errors.:smile::smile:

3 Likes

Edited with link mentioned :wink::grin:

Hi thunderboltz,

You overlooked the question. Important point in the question is Chef can purchase fruits at most K times. So I think from here you can know where you are going wrong.