Learning From the Past
Your company can make of the available trades on any given day. They have a list of potential profits for the three trades available for each of the past days, and want to know what the maximum possible profit for any of these days would've been so they can make better trade decisions in the future.
For each prior day , you're given three integers, , , and , denoting the profits that could've been made from each of that day's three available trades. You must analyze this data and determine the maximum profit your company could've earned by making exactly trades during each day . Then print a single integer denoting the maximum of these daily maximum potential profits.
Input Format
The first line contains a single integer, , denoting the number of days you must calculate the best possible trades for.
Each line of the subsequent lines contains three space-separated integers describing the respective values of , , and denoting the profits for the three possible trades for the prior day.
Constraints
Output Format
Print a single integer denoting the maximum possible profit that can be made from performing exactly two of the three available trades during one of the prior days.
Sample Input
2
1 2 3
3 3 0
Sample Output
6
Explanation
There are days to analyze:
- The maximum profit on the first day would be from making the second and third trades for a total profit of .
- The maximum profit for the second day would be from making the first and second trades for a total profit of .
We then print the maximum of these maximum possible profits for the prior days, which is , on a new line.
xxxxxxxxxx
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada;
procedure Solution is
-- Enter your code here. Read input from STDIN. Print output to STDOUT
end Solution