cho.sh
Notes
Loading...

Warehouse Relocation

Time limit

2s

Memory limit

128 MB

Problem

A company has an old warehouse with floors 1 through n and a new warehouse with floors 1 through m. For each floor of the old warehouse, you are given how many items are stored there. For each floor of the new warehouse, you are given the maximum number of items it can store. All items have the same size.

It may be impossible to move every item, so the company first wants to move as many items as possible. Among all ways to move that maximum number of items, it wants to minimize the total cost.

The company has hired k workers. One job takes one item from floor a of the old warehouse to floor b of the new warehouse. The cost of that job is a+b. Workers may repeat jobs, and each job moves exactly one item.

Compute the maximum number of items that can be moved and the minimum total cost for moving that many items.

Input

The first line contains three integers n, m, and k. (1 ≤ n, m, k ≤ 10,000)

The next n lines give, in order from floor 1 to floor n, the number of items stored on each floor of the old warehouse.

The following m lines give, in order from floor 1 to floor m, the maximum number of items that can be stored on each floor of the new warehouse.

Each stored item count and each capacity is a nonnegative integer not greater than 10,000.

Output

Print two integers x and y on the first line.

x is the maximum number of items that can be moved, and y is the minimum total cost required to move x items.