Problem
Chef has three spells. Their powers are
, , and respectively. Initially, Chef has hit points, and if he uses a spell with power , then his number of hit points increases by .
Before going to sleep, Chef wants to use exactly two spells out of these three. Find the maximum number of hit points Chef can have after using the spells.
Here is the Link to Problem : Chef and Spells CodeChef
Input Format
- The first line of the input contains a single integer denoting the number of test cases. The description of test cases follows.
- The first and only line of each test case contains three space-separated integers , , and .
Output Format
For each test case, print a single line containing one integer — the maximum number of hit points.
Constraints
Subtasks
Subtask #1 (100 points): original constraints
Sample 1:
Input
Output
2
4 2 8
10 14 18
12
32
Explanation:
Example case 1: Chef has three possible options:
- Use the first and second spell and have hitpoints.
- Use the second and third spell and have hitpoints.
- Use the first and third spell and have hitpoints.
Chef should choose the third option and use the spells with power and to have hitpoints.
Example case 2: Chef should use the spells with power and .
ANSWER
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main() { | |
// your code goes here | |
int t; | |
cin>>t; | |
while(t--) { | |
int a,b,c; | |
cin>>a>>b>>c; | |
int m = max(a+b,b+c); | |
int ans = max(a+c,m); | |
cout<<ans<<endl; | |
} | |
return 0; | |
} |