CF1379C Choosing flowers

题目描述

有 $m$ 种物品,每种物品有无限个,你可以购买 $n$ 个物品。 对于第 $i$ 种物品: 第一次买时的贡献是 $a_i$ ,接下来每购买一个的贡献都是 $b_i$。即当你买了 $x_i$ 个第 $i$ 种物品时,贡献是 $a_i+b_i \times (x_i-1)$ 现在要你求出最大贡献。

输入格式

输出格式

说明/提示

In the first example case Vladimir can pick 1 flower of the first type and 3 flowers of the second type, in this case the total happiness equals $ 5 + (1 + 2 \cdot 4) = 14 $ . In the second example Vladimir can pick 2 flowers of the first type, 2 flowers of the second type, and 1 flower of the third type, in this case the total happiness equals $ (5 + 1 \cdot 2) + (4 + 1 \cdot 2) + 3 = 16 $ .