A1399 | [COCI-2020-2021-olympiad]#1 Autobahn
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
There are N people testing their racing cars on notorious autobahn where limits do not exist. In this task however limits do exist. So we kindly ask you to restrain yourself from submitting exponential complexity solutions.
Person i came to autobahn at the beginning of minute li , paid for ti minutes of stay and left at the end of minute ri . Unfortunately some stayed for longer than that they have paid for. Administration of autobahn decided not to be very harsh and charge them only for those extra minutes in which there were at least K people on autobahn.
In a rush of generosity, administration decided to introduce happy hour i.e. interval of continuous X minutes for which they won’t be paying extra charges. They picked happy hour so that the sum of extra charges that won’t be paid is maximal possible. Determine that sum.
Person i came to autobahn at the beginning of minute li , paid for ti minutes of stay and left at the end of minute ri . Unfortunately some stayed for longer than that they have paid for. Administration of autobahn decided not to be very harsh and charge them only for those extra minutes in which there were at least K people on autobahn.
In a rush of generosity, administration decided to introduce happy hour i.e. interval of continuous X minutes for which they won’t be paying extra charges. They picked happy hour so that the sum of extra charges that won’t be paid is maximal possible. Determine that sum.
输入格式
First line contains integers N, K and X (K ≤ N) from task description.
Next N lines contain integers li , ti and ri (li ≤ ri) from task description.
Next N lines contain integers li , ti and ri (li ≤ ri) from task description.
输出格式
Print the required sum in a single line.
输入输出样例
输入 #1
5 3 4 2 1 4 3 3 7 3 3 8 1 5 7 5 3 8
输出 #1
7
Subtask Points Constraints
1 20 1 ≤ N, K, X, li, ti, ri ≤ 100
2 30 1 ≤ N, K, X, li, ti, ri ≤ 1 000
3 50 1 ≤ N ≤ 105, 1 ≤ X, li, ti, ri ≤ 109
First sample explanation: Happy hour will span from 4th until the 7th minute. Inside that interval,
first person should’ve paid extra for the 4th minute and second, third and fourth person should’ve paid
for 6th and 7th minute.
1 20 1 ≤ N, K, X, li, ti, ri ≤ 100
2 30 1 ≤ N, K, X, li, ti, ri ≤ 1 000
3 50 1 ≤ N ≤ 105, 1 ≤ X, li, ti, ri ≤ 109
First sample explanation: Happy hour will span from 4th until the 7th minute. Inside that interval,
first person should’ve paid extra for the 4th minute and second, third and fourth person should’ve paid
for 6th and 7th minute.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted