A12088 | TV Shows
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There are $n$ TV shows you want to watch. Suppose the whole time is split into equal parts called "minutes". The $i$ -th of the shows is going from $l_i$ -th to $r_i$ -th minute, both ends inclusive.
You need a TV to watch a TV show and you can't watch two TV shows which air at the same time on the same TV, so it is possible you will need multiple TVs in some minutes. For example, if segments $[l_i, r_i]$ and $[l_j, r_j]$ intersect, then shows $i$ and $j$ can't be watched simultaneously on one TV.
Once you start watching a show on some TV it is not possible to "move" it to another TV (since it would be too distracting), or to watch another show on the same TV until this show ends.
There is a TV Rental shop near you. It rents a TV for $x$ rupees, and charges $y$ ( $y < x$ ) rupees for every extra minute you keep the TV. So in order to rent a TV for minutes $[a; b]$ you will need to pay $x + y \cdot (b - a)$ .
You can assume, that taking and returning of the TV doesn't take any time and doesn't distract from watching other TV shows. Find the minimum possible cost to view all shows. Since this value could be too large, print it modulo $10^9 + 7$ .
You need a TV to watch a TV show and you can't watch two TV shows which air at the same time on the same TV, so it is possible you will need multiple TVs in some minutes. For example, if segments $[l_i, r_i]$ and $[l_j, r_j]$ intersect, then shows $i$ and $j$ can't be watched simultaneously on one TV.
Once you start watching a show on some TV it is not possible to "move" it to another TV (since it would be too distracting), or to watch another show on the same TV until this show ends.
There is a TV Rental shop near you. It rents a TV for $x$ rupees, and charges $y$ ( $y < x$ ) rupees for every extra minute you keep the TV. So in order to rent a TV for minutes $[a; b]$ you will need to pay $x + y \cdot (b - a)$ .
You can assume, that taking and returning of the TV doesn't take any time and doesn't distract from watching other TV shows. Find the minimum possible cost to view all shows. Since this value could be too large, print it modulo $10^9 + 7$ .
输入格式
The first line contains integers $n$ , $x$ and $y$ ( $1 \le n \le 10^5$ , $1 \le y < x \le 10^9$ ) — the number of TV shows, the cost to rent a TV for the first minute and the cost to rent a TV for every subsequent minute.
Each of the next $n$ lines contains two integers $l_i$ and $r_i$ ( $1 \le l_i \le r_i \le 10^9$ ) denoting the start and the end minute of the $i$ -th TV show.
Each of the next $n$ lines contains two integers $l_i$ and $r_i$ ( $1 \le l_i \le r_i \le 10^9$ ) denoting the start and the end minute of the $i$ -th TV show.
输出格式
Print exactly one integer — the minimum cost to view all the shows taken modulo $10^9 + 7$ .
输入输出样例
输入 #1
5 4 3 1 2 4 10 2 4 10 11 5 9
输出 #1
60
输入 #2
6 3 2 8 20 6 22 4 15 20 28 17 25 20 27
输出 #2
142
输入 #3
2 1000000000 2 1 2 2 3
输出 #3
999999997
In the first example, the optimal strategy would be to rent $3$ TVs to watch:
- Show $[1, 2]$ on the first TV,
- Show $[4, 10]$ on the second TV,
- Shows $[2, 4], [5, 9], [10, 11]$ on the third TV.
This way the cost for the first TV is $4 + 3 \cdot (2 - 1) = 7$ , for the second is $4 + 3 \cdot (10 - 4) = 22$ and for the third is $4 + 3 \cdot (11 - 2) = 31$ , which gives $60$ int total.
In the second example, it is optimal watch each show on a new TV.
In third example, it is optimal to watch both shows on a new TV. Note that the answer is to be printed modulo $10^9 + 7$ .
- Show $[1, 2]$ on the first TV,
- Show $[4, 10]$ on the second TV,
- Shows $[2, 4], [5, 9], [10, 11]$ on the third TV.
This way the cost for the first TV is $4 + 3 \cdot (2 - 1) = 7$ , for the second is $4 + 3 \cdot (10 - 4) = 22$ and for the third is $4 + 3 \cdot (11 - 2) = 31$ , which gives $60$ int total.
In the second example, it is optimal watch each show on a new TV.
In third example, it is optimal to watch both shows on a new TV. Note that the answer is to be printed modulo $10^9 + 7$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted