301155: CF215D. Hot Days

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

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$)。行中的数字用空格隔开。 ### 输出格式 一个整数,表示所需的最小代价。

题目描述

The official capital and the cultural capital of Berland are connected by a single road running through $ n $ regions. Each region has a unique climate, so the $ i $ -th $ (1<=i<=n) $ region has a stable temperature of $ t_{i} $ degrees in summer. This summer a group of $ m $ schoolchildren wants to get from the official capital to the cultural capital to visit museums and sights. The trip organizers transport the children between the cities in buses, but sometimes it is very hot. Specifically, if the bus is driving through the $ i $ -th region and has $ k $ schoolchildren, then the temperature inside the bus is $ t_{i}+k $ degrees. Of course, nobody likes it when the bus is hot. So, when the bus drives through the $ i $ -th region, if it has more than $ T_{i} $ degrees inside, each of the schoolchild in the bus demands compensation for the uncomfortable conditions. The compensation is as large as $ x_{i} $ rubles and it is charged in each region where the temperature in the bus exceeds the limit. To save money, the organizers of the trip may arbitrarily add or remove extra buses in the beginning of the trip, and between regions (of course, they need at least one bus to pass any region). The organizers can also arbitrarily sort the children into buses, however, each of buses in the $ i $ -th region will cost the organizers $ cost_{i} $ rubles. Please note that sorting children into buses takes no money. Your task is to find the minimum number of rubles, which the organizers will have to spend to transport all schoolchildren.

输入输出格式

输入格式


The first input line contains two integers $ n $ and $ m $ $ (1<=n<=10^{5} $ ; $ 1<=m<=10^{6}) $ — the number of regions on the way and the number of schoolchildren in the group, correspondingly. Next $ n $ lines contain four integers each: the $ i $ -th line contains $ t_{i} $ , $ T_{i} $ , $ x_{i} $ and $ cost_{i} $ ( $ 1<=t_{i},T_{i},x_{i},cost_{i}<=10^{6} $ ). The numbers in the lines are separated by single spaces.

输出格式


Print the only integer — the minimum number of roubles the organizers will have to spend to transport all schoolchildren. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.

输入输出样例

输入样例 #1

2 10
30 35 1 100
20 35 10 10

输出样例 #1

120

输入样例 #2

3 100
10 30 1000 1
5 10 1000 3
10 40 1000 100000

输出样例 #2

200065

说明

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.

Input

题意翻译

### 题意简述 $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$)。行中的数字用空格隔开。 ### 输出格式 一个整数,表示所需的最小代价。

加入题单

算法标签: