A12248 | Cloud Computing
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Buber is a Berland technology company that specializes in waste of investor's money. Recently Buber decided to transfer its infrastructure to a cloud. The company decided to rent CPU cores in the cloud for $n$ consecutive days, which are numbered from $1$ to $n$ . Buber requires $k$ CPU cores each day.
The cloud provider offers $m$ tariff plans, the $i$ -th tariff plan is characterized by the following parameters:
- $l_i$ and $r_i$ — the $i$ -th tariff plan is available only on days from $l_i$ to $r_i$ , inclusive,
- $c_i$ — the number of cores per day available for rent on the $i$ -th tariff plan,
- $p_i$ — the price of renting one core per day on the $i$ -th tariff plan.
Buber can arbitrarily share its computing core needs between the tariff plans. Every day Buber can rent an arbitrary number of cores (from 0 to $c_i$ ) on each of the available plans. The number of rented cores on a tariff plan can vary arbitrarily from day to day.
Find the minimum amount of money that Buber will pay for its work for $n$ days from $1$ to $n$ . If on a day the total number of cores for all available tariff plans is strictly less than $k$ , then this day Buber will have to work on fewer cores (and it rents all the available cores), otherwise Buber rents exactly $k$ cores this day.
The cloud provider offers $m$ tariff plans, the $i$ -th tariff plan is characterized by the following parameters:
- $l_i$ and $r_i$ — the $i$ -th tariff plan is available only on days from $l_i$ to $r_i$ , inclusive,
- $c_i$ — the number of cores per day available for rent on the $i$ -th tariff plan,
- $p_i$ — the price of renting one core per day on the $i$ -th tariff plan.
Buber can arbitrarily share its computing core needs between the tariff plans. Every day Buber can rent an arbitrary number of cores (from 0 to $c_i$ ) on each of the available plans. The number of rented cores on a tariff plan can vary arbitrarily from day to day.
Find the minimum amount of money that Buber will pay for its work for $n$ days from $1$ to $n$ . If on a day the total number of cores for all available tariff plans is strictly less than $k$ , then this day Buber will have to work on fewer cores (and it rents all the available cores), otherwise Buber rents exactly $k$ cores this day.
输入格式
The first line of the input contains three integers $n$ , $k$ and $m$ ( $1 \le n,k \le 10^6, 1 \le m \le 2\cdot10^5$ ) — the number of days to analyze, the desired daily number of cores, the number of tariff plans.
The following $m$ lines contain descriptions of tariff plans, one description per line. Each line contains four integers $l_i$ , $r_i$ , $c_i$ , $p_i$ ( $1 \le l_i \le r_i \le n$ , $1 \le c_i, p_i \le 10^6$ ), where $l_i$ and $r_i$ are starting and finishing days of the $i$ -th tariff plan, $c_i$ — number of cores, $p_i$ — price of a single core for daily rent on the $i$ -th tariff plan.
The following $m$ lines contain descriptions of tariff plans, one description per line. Each line contains four integers $l_i$ , $r_i$ , $c_i$ , $p_i$ ( $1 \le l_i \le r_i \le n$ , $1 \le c_i, p_i \le 10^6$ ), where $l_i$ and $r_i$ are starting and finishing days of the $i$ -th tariff plan, $c_i$ — number of cores, $p_i$ — price of a single core for daily rent on the $i$ -th tariff plan.
输出格式
Print a single integer number — the minimal amount of money that Buber will pay.
输入输出样例
输入 #1
5 7 3 1 4 5 3 1 3 5 2 2 5 10 1
输出 #1
44
输入 #2
7 13 5 2 3 10 7 3 5 10 10 1 2 10 6 4 5 10 9 3 4 10 8
输出 #2
462
输入 #3
4 100 3 3 3 2 5 1 1 3 2 2 4 4 4
输出 #3
64
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted