
P

R

O

G

R

A

M

M

I

N

G


C

O

M

P

E

T

I

T

I

O

N


Job
Processing



Task Description
A factory
is running a production line. Two operations have to be performed on each job:
first operation "A", then operation "B". There is a certain number of machines
capable of performing each operation.

Source: 8th International Olympiad in Informatics, Veszprém,
Hungary
http://www.inf.bme.hu/contests/tasks/ioi96d1.html
Program Input
The
input file contains positive integers in five lines. The first line contains
N, the number of jobs (1<=N<=1000). On the second line, the number M1 of type
"A" machines (1<=M1<=30) is given. In the third line there are M1 integers, the
job processing times of each type "A" machine. The fourth and the fifth line
contain the number M2 of type "B" machines (1<=M2<=30) and the job processing
times of each type "B" machine, respectively. The job processing time is measured
in units of time, which includes the time needed for taking a job from a container
before processing and putting it into a container after processing. Each processing
time is at least 1 and at most 20.
5
2
1 1
3
3 1 4
Program Output
Your
program should write two lines to the output file. The first line should contain
the solution of subtask A. The second line should contain the solution of subtask
B. The program must write the sentence labels as shown in the example below:
Minimum time to complete subtask A: 3
Minimum time to complete subtask B: 5