Canadian Computing Olympiad: 2017 Day 2, Problem 1
It was a dark and stormy night. It also rained, and rained, and rained.
Lucy wants to capture some of the rain, but she only has limited materials. She has a collection of pillars of various heights, which she can configure to capture the rain. Each pillar has an integer height and has a length and width of
For example, if Lucy has pillars of height
*
* *
* *
** *
*****
which would capture R
) as follows:
*
*RR*
*RR*
**R*
*****
For this first collection of pillars
*
*RR*
*RR*
**RR*
*****
As another example, if the collection of pillars was
*R*R*
*R*R*
*R*R*
*R*R*
*****
Finally, this configuration of
*RRR*
*R*R*
*R*R*
*R*R*
*****
Lucy has
Input Specification
The first line contains the integer
For 5 of the 25 marks available,
For an additional 10 of the 25 marks available,
Output Specification
On one line, output a space-separated list of all possible obtainable integer volumes of rain captured, in increasing order.
Sample Input 1
5
1 5 2 1 4
Sample Output 1
0 1 2 3 4 5 6 8
Explanation for Sample Output 1
This is the first given example.
Sample Input 2
5
5 1 5 1 5
Sample Output 2
0 4 8
Explanation for Sample Output 2
This is the second given example.
Sample Input 3
5
5 1 4 1 5
Sample Output 3
0 1 3 4 5 6 7 8 9
Explanation for Sample Output 3
This is the third given example.
Comments