CodechefMay 08, 2025

Water Mixing

Hazrat Ali

Codechef

Chef is setting up a perfect bath for himself. He has XX litres of hot water and YY litres of cold water.
The initial temperature of water in his bathtub is AA degrees. On mixing water, the temperature of the bathtub changes as following:

  • The temperature rises by 11 degree on mixing 11 litre of hot water.
  • The temperature drops by 11 degree on mixing 11 litre of cold water.

Determine whether he can set the temperature to BB degrees for a perfect bath.

Input Format

  • The first line of input will contain a single integer TT, denoting the number of test cases.
  • Each test case consists of four space-separated integers A,B,X,A,B,X, and YY — the initial temperature of bathtub, the desired temperature of bathtub, the amount of hot water in litres, and the amount of cold water in litres respectively.

Output Format

For each test case, output on a new line, YES if Chef can get the desired temperature for his bath, and NO otherwise.

You may print each character of the string in uppercase or lowercase (for example, the strings YESyEsyes, and yeS will all be treated as identical).

Constraints

  • 1≤T≤2000
  • 20≤A,B≤40
  • 0≤X,Y≤20

Sample 1:

Input
 
4
24 25 2 0
37 37 2 9
30 20 10 9
30 31 0 20
 
Output
 
YES
YES
NO
NO
 

Explanation:

Test case 11: The initial temperature of water is 2424 and the desired temperature is 2525. Chef has 22 litres of hot water. He can add 11 litre hot water in the tub and change the temperature to 24+1=25 degrees.

Test case 22: The initial temperature of water is 3737 and the desired temperature is also 3737. Thus, Chef does not need to add any more water in the bathtub.

Test case 33: The initial temperature of water is 3030 and the desired temperature is 2020. Chef needs to add 1010 litres of cold water to reach the desired temperature. Since he only has 99 litres of cold water, he cannot reach the desired temperature.

Test case 44: The initial temperature of water is 3030 and the desired temperature is 3131. Chef needs to add 11 litre of hot water to reach the desired temperature. Since he has no hot water, he cannot reach the desired temperature.

 

Solution 

for _ in range(int(input())):
    x,y,z,m=map(int,input().split())
    if(x<=y):
        if(y-x<=z):
            print("yes")
        else:
            print("no")
    else:
        if(x-y<=m):
            print("yes")
        else:
            print("no")

 

 

Comments