Leaves and bees

It is spring! The vegetable garden of our friend Pau Gargallo is full of flowers. However, and for reasons difficult to explain (and that they don’t mind) we are more interested in the leaves. Pau only let us to cut plants with flower, and he charges us FF cents of euro for each flowered plant that we cut; moreover, we know that we can obtain LL cents of euro for each leaf that we sell in the black market of collectors of leaves. ?‘Would you know to tell us which is the maximal profit that we can obtain, and how many plants we should cut to reach it? In case that there were many different ways to reach the same profit, our lazy nature drives us to accept only as correct answer the one which requires to cut the minimal number of plants.

A small detail: some flowers have bees! Under any circumstances we dare to cut plants which flower has at least a bee.

Input

An input contains only a garden. The first line of the garden contains the numbers 0F10000\le F\le 1000, 0L10000\le L\le 1000 and 3m10003\le m\le 1000, that are, respectively, the cost of cutting a plant, the profit that we obtain per leaf, and the length of the garden. The description of a garden of length mm takes up mm lines. (look the instances of the input to undestand better the explanation).

The plants placed in the first and the last position of the garden never will have flowers. The characters of two different plants will never superimpose.

Output

Your program must print two lines, each one of them ended in a return of line. In the first line it must print the maximal profit that can be obtained from the garden in euro cents, and in the second line the minimal number of necessary cuts to reach it.

Scoring

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:31:53.455Z

© Jutge.org, 2006–2026.
https://jutge.org