CF215D Hot Days
题目描述
### 题意简述
$A$ 地和 $B$ 地由一条贯穿 $n$ 个区域的公路连接起来。每个区域都有独特的气候,所以第 $i$ $\left(1\le i \le n\right)$ 个区域的夏季气温会稳定在 $t_i$ 度。
有 $m$ 个学生要从 $A$ 地到 $B$ 地去旅游,他们乘坐大巴车旅游,但巴士内的温度会随地区与车内人数的变化而变化,行驶在第 $i$ 个地区的温度为 $t_i+k$ ( $k$ 为车内人数),但当车内温度超过 $T_i$ 时,学生会要求组织旅行的人赔偿,需赔偿每人 $x_i$ 元。
组织者需要在每个地区**都**购买任意数量公交车以完成旅行,且他们可以分配孩子到公交车上,分配不需要代价,在第 $i$ 个地区买一辆公交车需 $cost_i$ 。
输入格式
第一行输入包含两个整数 $n$ 和 $m$ ($1\le n≤10^5$,$1\le m\le10^6$)
接下来的 $n$ 行分别包含 $4$ 个整数:第 $i$ 行包含 $t_i$,$T_i$,$x_i$ 和 $cost_i$( $1\le t_i,T_i,x_i,cost_i\le10^6$)。行中的数字用空格隔开。
输出格式
一个整数,表示所需的最小代价。
说明/提示
In the first sample the organizers will use only one bus to travel through the first region. However, the temperature in the bus will equal $ 30+10=40 $ degrees and each of $ 10 $ schoolchildren will ask for compensation. Only one bus will transport the group through the second region too, but the temperature inside won't exceed the limit. Overall, the organizers will spend $ 100+10+10=120 $ rubles.