CodechefApr 08, 2025

Monopoly

Hazrat Ali

Codechef

There are 44 companies in the markets of Chefland, AABBCC, and DD.This year,

  • Company AA made a profit of PP lakh rupees,
  • Company BB made a profit of QQ lakh rupees,
  • Company CC made a profit of RR lakh rupees,
  • Company DD made a profit of SS lakh rupees.

There is said to be a monopoly in the market if the profit made by one company is strictly greater than the sum of profits made by all other companies.Determine if there is a monopoly in the market or not.

Input Format

  • The first line of input will contain a single integer TT, denoting the number of test cases.
  • The first line and only line of each test case contains four space-separated integers PPQQRR and SS — the profits made by companies AABBCC and DD respectively.

Output Format

For each test case, output YES if there is a monopoly in the market. Otherwise, output NO.

You may print each character of YES and NO in uppercase or lowercase (for example, yesyEsYes will be considered identical).

Constraints

  • 1≤T≤5000
  • 1≤P,Q,R,S≤100

Sample 1:

Input
 
Output
 
4
1 1 1 10
30 20 6 4
100 90 3 4
14 15 16 17
YES
NO
YES
NO

Explanation:

Test Case 1: Here, company DD's profit (1010) is greater than the sum of profits of all other companies (1+1+1=3).

Test Case 2: Here, no company's profit is strictly greater than the sum of profits of all other companies.

Test Case 3: Here, company AA's profit (100100) is greater than the sum of profits of all other companies (90+3+4=97).

 

Solution 

m=int(input())
for i in range(m):
    a,b,c,d=map(int,input().split())
    if a+b+c<d:
        print("yes")
    elif b+c+d<a:
        print("yes")
    elif a+b+d<c:
        print("yes")
    elif a+c+d<b:
        print("yes")
    else:
        print("no")

 

 

 

 

Comments