CodechefJun 05, 2025

Maximise the Tastiness

Hazrat Ali

Codechef

Chef is making a dish that consists of exactly two ingredients. He has four ingredients A,B,CA,B,C and DD with tastiness a,b,c,a,b,c, and dd respectively. He can use either AA or BB as the first ingredient and either CC or DD as the second ingredient.

The tastiness of a dish is the sum of tastiness of its ingredients. Find the maximum possible tastiness of the dish that the chef can prepare.

Input Format

  • The first line of input will contain a single integer TT, denoting the number of test cases.
  • The first and only line of each test case contains four space-separated integers a,b,c,a,b,c, and dd — the tastiness of the four ingredients.

Output Format

For each test case, output on a new line the maximum possible tastiness of the dish that chef can prepare.

Constraints

  • 1≤T≤100
  • 1≤a,b,c,d≤100

Sample 1:

Input
2
3 5 6 2
16 15 5 4

Output
11
21

Solution
t = int(input())
while t != 0:
    a, b, c, d = map(int, input().split())
    maximise1 = max(a, b)
    maximise2 = max(c, d)
    print(maximise1 + maximise2)
    t -= 1




 

Comments