A8618 | Transportation
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Valera came to Japan and bought many robots for his research. He's already at the airport, the plane will fly very soon and Valera urgently needs to bring all robots to the luggage compartment.
The robots are self-propelled (they can potentially move on their own), some of them even have compartments to carry other robots. More precisely, for the $i$ -th robot we know value $c_{i}$ — the number of robots it can carry. In this case, each of $c_{i}$ transported robots can additionally carry other robots.
However, the robots need to be filled with fuel to go, so Valera spent all his last money and bought $S$ liters of fuel. He learned that each robot has a restriction on travel distances. Thus, in addition to features $c_{i}$ , the $i$ -th robot has two features $f_{i}$ and $l_{i}$ — the amount of fuel (in liters) needed to move the $i$ -th robot, and the maximum distance that the robot can go.
Due to the limited amount of time and fuel, Valera wants to move the maximum number of robots to the luggage compartment. He operates as follows.
- First Valera selects some robots that will travel to the luggage compartment on their own. In this case the total amount of fuel required to move all these robots must not exceed $S$ .
- Then Valera seats the robots into the compartments, so as to transport as many robots as possible. Note that if a robot doesn't move by itself, you can put it in another not moving robot that is moved directly or indirectly by a moving robot.
- After that all selected and seated robots along with Valera go to the luggage compartment and the rest robots will be lost.
There are $d$ meters to the luggage compartment. Therefore, the robots that will carry the rest, must have feature $l_{i}$ of not less than $d$ . During the moving Valera cannot stop or change the location of the robots in any way.
Help Valera calculate the maximum number of robots that he will be able to take home, and the minimum amount of fuel he will have to spend, because the remaining fuel will come in handy in Valera's research.
The robots are self-propelled (they can potentially move on their own), some of them even have compartments to carry other robots. More precisely, for the $i$ -th robot we know value $c_{i}$ — the number of robots it can carry. In this case, each of $c_{i}$ transported robots can additionally carry other robots.
However, the robots need to be filled with fuel to go, so Valera spent all his last money and bought $S$ liters of fuel. He learned that each robot has a restriction on travel distances. Thus, in addition to features $c_{i}$ , the $i$ -th robot has two features $f_{i}$ and $l_{i}$ — the amount of fuel (in liters) needed to move the $i$ -th robot, and the maximum distance that the robot can go.
Due to the limited amount of time and fuel, Valera wants to move the maximum number of robots to the luggage compartment. He operates as follows.
- First Valera selects some robots that will travel to the luggage compartment on their own. In this case the total amount of fuel required to move all these robots must not exceed $S$ .
- Then Valera seats the robots into the compartments, so as to transport as many robots as possible. Note that if a robot doesn't move by itself, you can put it in another not moving robot that is moved directly or indirectly by a moving robot.
- After that all selected and seated robots along with Valera go to the luggage compartment and the rest robots will be lost.
There are $d$ meters to the luggage compartment. Therefore, the robots that will carry the rest, must have feature $l_{i}$ of not less than $d$ . During the moving Valera cannot stop or change the location of the robots in any way.
Help Valera calculate the maximum number of robots that he will be able to take home, and the minimum amount of fuel he will have to spend, because the remaining fuel will come in handy in Valera's research.
输入格式
The first line contains three space-separated integers $n,d,S$ $(1<=n<=10^{5},1<=d,S<=10^{9})$ . The first number represents the number of robots, the second one — the distance to the luggage compartment and the third one — the amount of available fuel.
Next $n$ lines specify the robots. The $i$ -th line contains three space-separated integers $c_{i},f_{i},l_{i}$ $(0<=c_{i},f_{i},l_{i}<=10^{9})$ — the $i$ -th robot's features. The first number is the number of robots the $i$ -th robot can carry, the second number is the amount of fuel needed for the $i$ -th robot to move and the third one shows the maximum distance the $i$ -th robot can go.
Next $n$ lines specify the robots. The $i$ -th line contains three space-separated integers $c_{i},f_{i},l_{i}$ $(0<=c_{i},f_{i},l_{i}<=10^{9})$ — the $i$ -th robot's features. The first number is the number of robots the $i$ -th robot can carry, the second number is the amount of fuel needed for the $i$ -th robot to move and the third one shows the maximum distance the $i$ -th robot can go.
输出格式
Print two space-separated integers — the maximum number of robots Valera can transport to the luggage compartment and the minimum amount of fuel he will need for that. If Valera won't manage to get any robots to the luggage compartment, print two zeroes.
输入输出样例
输入 #1
3 10 10 0 12 10 1 6 10 0 1 1
输出 #1
2 6
输入 #2
2 7 10 3 12 10 5 16 8
输出 #2
0 0
输入 #3
4 8 10 0 12 3 1 1 0 0 3 11 1 6 9
输出 #3
4 9
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted