#K47297. Checkpoint Refreshment

    ID: 28167 Type: Default 1000ms 256MiB

Checkpoint Refreshment

Checkpoint Refreshment

In this problem, a runner passes through n checkpoints. At each checkpoint, there are three types of refreshments available: water, energy drink, and snack. Each refreshment has an associated happiness score. The runner may choose exactly one refreshment at each checkpoint.

Your task is to compute the maximum total happiness the runner can achieve by selecting the refreshment with the maximum happiness score at each checkpoint. Formally, if the happiness scores for water, energy drink, and snack at the i-th checkpoint are represented as \(w_i\), \(e_i\), and \(s_i\), respectively, then the maximum total happiness is given by:

[ \text{Total Happiness} = \sum_{i=1}^{n} \max(w_i, e_i, s_i)
]

Input is provided via standard input and the output should be printed to standard output.

inputFormat

The first line of input contains a single integer n (1 ≤ n ≤ 105), representing the number of checkpoints.

The following n lines each contain three space-separated integers w, e, and s (0 ≤ w, e, s ≤ 109), which denote the happiness scores for water, energy drinks, and snacks respectively at that checkpoint.

outputFormat

Output a single integer representing the maximum total happiness score the runner can achieve.

## sample
1
10 20 30
30