Help me in solving TWODISH problem

My issue

In the code, I first check if 2 dishes can be made and then verify if the input can make the required number of dishes. Is this approach correct? I am getting the desired output but not for all test cases.

My code

#include <stdio.h>

int main(void) {
	// your code goes here
	int t;
	scanf("%d",&t);
	while(t--)
	{
	    int n,a,b,c;
	    scanf("%d%d%d%d",&n,&a,&b,&c);
	    if(b-a>=c && a+c>=n)
	    {
	        printf("YES\n");
	    }
	    else
	    {
	        printf("NO\n");
	    }
	}
	return 0;
}


Problem Link: CodeChef: Practical coding for everyone

hi,
the logic is slightly wrong in if statement it should be if( b>=n &&a+c>=n)
try with this.as the condition must have relation with number of guests.

1 Like

@sheetalme10
Hello!
Thank you. It’s working.