#P1846. 游戏
游戏
Description
Given two sequences of positive integers, you will play a game with them: you need to perform several operations. In each operation, choose two positive integers and , remove the last numbers of the first sequence and compute their sum ; remove the last numbers of the second sequence and compute their sum . The score of this operation is . Both sequences must become empty at the same time; it is not allowed for one sequence to be empty while the other still contains numbers. The total score of the game is the sum of the scores of all operations.
Find the minimum possible total score.
Input Format
The first line contains two integers and , the initial lengths of the first and second sequences, respectively.
The second line contains positive integers, the numbers of the first sequence.
The third line contains positive integers, the numbers of the second sequence.
All numbers in the sequences are at most .
Output Format
Output a single integer, the minimum total score.
3 2
1 2 3
1 2
2
Hint
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号