Book 1-on-1 live assistance from the navigation menu
I'm just a message away. Let's solve it together. 👨💻
Search Questions
Company: AXION
#1
Finally, a basketball court has been opened in SIS, so Demid has decided to hold a basketball exercise session. 2 * n students have come to Demid's exercise session, and he lined them up into two rows of the same size (there are exactly n people in each row). Students are numbered from 1 to n in each row in order from left to right.
Now Demid wants to choose a team to play basketball. He will c
hoose players from left to right, and the index of each chosen player (excluding the first one taken) will be strictly greater than the index of the previously chosen player. To avoid giving preference to one of the rows, Demid chooses students in such a way that no consecutive chosen students belong to the same row.
The first student can be chosen among all 2n students (there are no additional constraints), and a team can consist of any number of students. Demid thinks that in order to compose a perfect team, he should choose students in such a way that the total height of all chosen students is maximum possible. Help Demid to find the maximum possible total height of players in a team he can choose.
Array or integers. The first element is n. The next n elements are the heights of the students in the first row. The next n elements are the heights of the students in the second row.
Output Print a single integer - the maximum possible total height of players in a team Demid can choose.