CF734C Anton and Making Potions

Description

Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare $ n $ potions. Anton has a special kettle, that can prepare one potions in $ x $ seconds. Also, he knows spells of two types that can faster the process of preparing potions. 1. Spells of this type speed up the preparation time of one potion. There are $ m $ spells of this type, the $ i $ -th of them costs $ b_{i} $ manapoints and changes the preparation time of each potion to $ a_{i} $ instead of $ x $ . 2. Spells of this type immediately prepare some number of potions. There are $ k $ such spells, the $ i $ -th of them costs $ d_{i} $ manapoints and instantly create $ c_{i} $ potions. Anton can use no more than one spell of the first type and no more than one spell of the second type, and the total number of manapoints spent should not exceed $ s $ . Consider that all spells are used instantly and right before Anton starts to prepare potions. Anton wants to get to the next level as fast as possible, so he is interested in the minimum number of time he needs to spent in order to prepare at least $ n $ potions.

Input Format

The first line of the input contains three integers $ n $ , $ m $ , $ k $ ( $ 1

Output Format

Print one integer — the minimum time one has to spent in order to prepare $ n $ potions.

Explanation/Hint

In the first sample, the optimum answer is to use the second spell of the first type that costs $ 10 $ manapoints. Thus, the preparation time of each potion changes to $ 4 $ seconds. Also, Anton should use the second spell of the second type to instantly prepare $ 15 $ potions spending $ 80 $ manapoints. The total number of manapoints used is $ 10+80=90 $ , and the preparation time is $ 4·5=20 $ seconds ( $ 15 $ potions were prepared instantly, and the remaining $ 5 $ will take $ 4 $ seconds each). In the second sample, Anton can't use any of the spells, so he just prepares $ 20 $ potions, spending $ 10 $ seconds on each of them and the answer is $ 20·10=200 $ .