#K74572. Max Seatable Guests Problem

    ID: 34227 Type: Default 1000ms 256MiB

Max Seatable Guests Problem

Max Seatable Guests Problem

You are given details about guest groups and seating sections at an event. Although the sizes of the guest groups are provided, the seating arrangement is governed solely by the seating capacities of the sections. Your task is to determine the maximum number of guests that can be seated together in any section without exceeding that section's seating limit.

The first integer n represents the number of guest groups. The next line contains n integers representing the sizes of these guest groups. The following integer m denotes the number of seating sections, and the next line contains m integers representing the seating capacities of each section.

Note: Although the guest group sizes are given, they are not used in computing the answer. The answer is simply the maximum value among the seating capacities. Express any mathematical formulas in LaTeX format if needed. For example, the answer is:

$$\max_{1 \leq i \leq m} \text{{capacity}}_i$$

inputFormat

The input is given from stdin in the following format:

Line 1: An integer n — the number of guest groups
Line 2: n space-separated integers representing the sizes of each guest group
Line 3: An integer m — the number of seating sections
Line 4: m space-separated integers representing the seating capacity of each section

outputFormat

Output a single integer to stdout — the maximum seating capacity among all sections.

## sample
4
4 8 3 5
3
10 12 6
12