Two Dishes solution codechef

Two Dishes solution codechef

Chef will have NN guests in his house today. He wants to serve at least one dish to each of the NN guests. Chef can make two types of dishes. He needs one fruit and one vegetable to make the first type of dish and one vegetable and one fish to make the second type of dish. Now Chef has AA fruits, BB vegetables, and CC fishes in his house. Can he prepare at least NN dishes in total?

  • First line will contain TT, number of testcases. Then the testcases follow.
  • Each testcase contains of a single line of input, four integers N,A,B,CN,A,B,C.

Output Format

For each test case, print “YES” if Chef can prepare at least NN dishes, otherwise print “NO”. Print the output without quotes.

  • 1T1001≤T≤100
  • 1N,A,B,C1001≤N,A,B,C≤100

Subtasks

  • Subtask 1 (100 points): Original constraints

Sample Input 1 

4
2 1 2 1
3 2 2 2
4 2 6 3
3 1 3 1

Two Dishes solution codechef

 

YES
NO
YES
NO

Explanation

Test case 11: Chef prepares one dish of the first type using one fruit and one vegetable and another dish of the second type using one vegetable and one fish.

Test case 22: Chef prepares two dishes of the first type using two fruit and two vegetable. Now all the vegetables are exhausted, hence he can’t prepare any other dishes.

Test case 33: Chef can prepare a total of 55 dishes, two dishes of the first type and three dishes of the second type.

Two Dishes solution codechef

Leave a Reply

Your email address will not be published. Required fields are marked *

*