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 ?
The first row contains , the second row contains , and the third row contains .
for all .
Output the maximum sum of a valid subsequence of (The subsequence can be empty, in which case the sum would be 0).
5 6 5 6 5 6 6 1 4
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.