~/algor $ cat problems/dp-tatil-kunlari
Vacation days
Easy
1000 ms
128 MB
30%
A vacation lasts $n$ days. Each day you may choose one of three activities: swimming, hiking in the mountains or reading a book. On day $i$ they bring $a_{i}$, $b_{i}$ and $c_{i}$ points of joy respectively. The same activity cannot be done on two consecutive days. What is the largest amount of joy you can get during the vacation?
Input
The first line contains a positive integer $n$. Each of the next $n$ lines contains three positive integers: $a_{i}$, $b_{i}$ and $c_{i}$.
Output
One integer — the largest joy.
Note
$1 \le n \le 10^{5}$
$1 \le a_{i}, b_{i}, c_{i} \le 10^{4}$
Examples
Input #1
3 10 40 70 20 50 80 30 60 90
Output #1
210
Input #2
1 5 9 2
Output #2
9