QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#13203. Magic Spectacle Case

Statistics

Xiao Hua has bought a very interesting magic glasses case. The case lid consists of two halves, each horizontally divided into several paper strips, as shown in Figure 1 (the left half is the bottom of the case, and the right half is the top). The gray areas represent the surface of the case, and the white areas represent empty regions. The glasses case in the figure has 3 paper strips, each with a length of 50 mm, but other cases may have a different number of strips, and the length of each strip may not be the same.

Figure 1. Two folding methods of the magic glasses case

The special feature of the glasses case is that it has two folding methods. Figure 1 (a) and (b) show these two methods. The first method exposes regions 1, 2, and 3 on the surface of the case, while the second method exposes regions 4, 5, and 6. If a glasses case has $n$ paper strips, the regions exposed by folding method 1 are numbered $1, 2, \dots, n$, and the regions exposed by folding method 2 are numbered $n+1, n+2, \dots, 2n$. The $i$-th region and the $(n+i)$-th region are congruent. In this problem, you do not need to understand how the two folding methods are transformed into each other.

Xiao Hua has two types of square paper pieces: formula sheets and cartoon pictures. She wants to stick the formula sheets in regions $1, 2, 3$ and the cartoon pictures in $4, 5, 6$. She uses folding method 1 when studying and folding method 2 when resting. Each paper piece must be placed entirely within the interior of a region; the boundaries of the paper piece may coincide with the boundaries of the region. Different paper pieces must be placed in different regions, and some regions may not have any paper pieces.

A standard glasses case has a length of 150, a width of 55, and an area of 8250, divided into three equal-length paper strips, so each white region has dimensions $55 \times 50$. Xiao Hua has 3 formula sheets with side lengths of 40, 45, and 52, and 4 cartoon pictures with side lengths of 10, 27, 30, and 55. She can only place the 40 and 45 sheets on the front, and the 10, 27, and 30 sheets on the back. Clearly, the standard glasses case does not meet Xiao Hua's requirements.

Fortunately, the glasses case company allows users to customize their own cases. The length of the case, the width, the number of paper strips, and the length of each strip can all be modified arbitrarily; that is, the length does not have to be 150, and the width does not have to be 55. Xiao Hua discovered that if the case dimensions remain the same, but she replaces them with four paper strips of lengths 40, 45, 55, and 10, all the paper pieces can be placed, as shown in Figure 2.

Figure 2. A customized glasses case that can hold all the paper pieces

Glasses cases with larger areas are more expensive, so Xiao Hua wants to buy a case with an area not exceeding $s$. How should she choose the glasses case, design the paper strips, and place the small paper pieces to maximize the total number of paper pieces on the case? Given that the number of paper pieces is maximized, what is the minimum area of the glasses case?

Input

The first line of the input contains three integers $n$, $m$, and $s$, representing the number of formula sheets, the number of cartoon pictures, and the upper limit of the glasses case area, respectively. The second line contains $n$ positive integers, representing the side lengths of each formula sheet. The third line contains $m$ positive integers, representing the side lengths of each cartoon picture.

Output

The output contains a single line with two integers $C_{max}$ and $S_{min}$, representing the maximum number of paper pieces that can be placed on the case and the minimum area of the glasses case under this condition.

Examples

Input 1

3 4 10000
40 45 52
10 27 30 55

Output 1

7 8250

Constraints

$1 \le n, m \le 50,000$, $1 \le s \le 10^{13}$, all paper piece side lengths do not exceed 40,000. 50% of the data satisfies $1 \le n, m \le 1,000$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.