## UTS Open '18 P2 - ABCs

View as PDF

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M
Author:

Problem type

You have 3 sequences , , and , each containing 3 integers. A subsequence of is valid if for each in the subsequence, = (indices are taken mod 3, so ).

What is the maximum sum of a valid subsequence of ?

#### Input Format

The first row contains , the second row contains , and the third row contains .

for all .

#### Output Format

Output the maximum sum of a valid subsequence of (The subsequence can be empty, in which case the sum would be 0).

#### Sample Input

5 6 5
6 5 6
6 1 4

#### Sample Output

5

#### Explanation for Sample Output

Since and , and are valid and can be included in the subsequence. However, , so cannot be included in the subsequence. This subsequence has sum 5.