P2374 Porter

Background

Mr. Chen likes buying books online. He often purchases a hundred or so at a time and then resells them for profit.

Description

A few days ago, the new Grade 10 students arrived. As usual, he tried to sell his books to them. After some persuasion, the students decided to buy his books. However, there are three stacks of books on Mr. Chen’s desk, each forming a thick pile. He wants to find the easiest way to hand the books to the students, but you want to tease him by designing the most exhausting way. You are given that the three stacks have $i$,$j$,$k$ books, respectively, as well as the weight of each book in each stack from bottom to top. Each time he takes a book, he can only take the top book from any one stack. Please design an order that makes him expend the maximum effort to take down all the books. Obviously, his effort increases with each book he takes. We define an effort coefficient: when taking the first book, the coefficient is $1$; for the second book, it is $2$; and so on. The effort cost for each operation equals the product of the current effort coefficient and the book’s weight.

Input Format

The first line contains three integers, the numbers of books in the three stacks $i$,$j$,$k$. The second to fourth lines give the weights of the books in each stack, listed from bottom to top.

Output Format

Output the total effort cost under the most exhausting order.

Explanation/Hint

#### Constraints - For $50\%$ of the testdata, $0\le i,j,k\lt10$。 - For $100\%$ of the testdata, $0\le i,j,k\lt100$。 The final total effort cost fits in the C++ int range. Translated by ChatGPT 5