Problems
10165 - Containers
SUBMIT PROBLEM

Containers

Time Limit: 2 sec

 

The Problem

There are N number of containers in a store room. Each container has an integer value (can be negative). You have to add some number with the max container.

For example store room has 4 containers with initial values  4,-2, 1, 2. Now add some number with max container. Suppose you have to add -3, -1, -1, 9. In every step you have to add a number with the max container of current state. An explanation is given below.

4+-3       2+-1      1+-1        (1+9)

4 -2  1 21 -2  1 2 1 -2  1 10 -2  1 10 -2  10 1{10  1 0 -2}

 

The Input

Input will contain several test cases. Each test case starts with a non negative integer number N (N<=10^5). The next line will contain N space separated integer number Ni (-10^4 <= Ni <=10^4), the containers initial states. The next line is a non negative integer  M (1<= M <= 10^4) the amount of number needs to add with containers value. The last line of each test case is M space separated integer number Mi (-10^4 <= Mi <=10^4) that you have added with max container. The input will terminated by a line N = 0.

 

The Output

The output will contain two lines for each test case. First line of the output will contain “Case C#”, where C denotes the case number starting from 1. And the second line will contain the final state of the containers in descending order. See the sample input and output section for more clarification.

 

Sample Input

4

4 -2 1 2

4

-3 -1 -1 9 

6

10 5 -10 20 5 6

5

5 -20 4 -10 20

0

 

Sample Output

Case 1#

10 1 0 -2

Case 2#

26 5 5 5 4 -10

 

 

Intra University Programming Contest - Winter 2019 [BGC Trust University Bangladesh]

Problem Setter: Milton Deb