#P9814. [CCC 2015 S5] Greedy For Pies
[CCC 2015 S5] Greedy For Pies
Problem Description
Given a sequence of length and a sequence of length , you may insert the elements of sequence into sequence at any positions you like (including the beginning and the end). After that, you may choose some elements from the new sequence, but you are not allowed to choose two adjacent elements.
You need to maximize the sum of the chosen numbers, and output this maximum value.
Input Format
The first line contains an integer .
The next lines each contain an integer .
Then one line contains an integer .
The next lines each contain an integer .
Output Format
Output one line containing one integer, which is the maximum possible sum of elements you can choose.
5
10
12
6
14
7
3
1
8
2
44
Hint
Constraints:
For of the testdata, .
For another of the testdata, .
For another of the testdata, .
For of the testdata, , , .
Translated by ChatGPT 5