[Solution] Maximise the Tastiness solution codechef

Maximise the Tastiness solution 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.

Table of Contents

[Solution] Maximise the Tastiness solution codechef

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.

[Solution] Maximise the Tastiness solution codechef

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

Sample Input 1 

2
3 5 6 2
16 15 5 4

Sample Output 1 

11
21

[Solution] Maximise the Tastiness solution codechef

Test case 11: Chef can prepare a dish with ingredients BB and CC with a tastiness of 5+6=115+6=11.

Test case 22: Chef can prepare a dish with ingredients AA and CC with a tastiness of 16+5=2116+5=21.

For Solution

Click Here

Leave a Comment