CF203E.Transportation

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

瓦列拉来到日本,为他的研究购买了许多机器人。他此刻已抵达机场,飞机即将起飞,瓦列拉急需将所有机器人运送到行李舱。

这些机器人具备自主移动能力(理论上可自行运动),其中一些甚至拥有可搭载其他机器人的舱室。更准确地说,对于第 ii 个机器人,我们已知其承载能力 cic_i —— 即它最多可携带的机器人数量。此时,这 cic_i 个被运输的机器人还可进一步各自携带其他机器人。

然而,机器人需要加注燃料才能运行,因此瓦列拉花光了最后的钱,仅购得 SS 升燃料。他还了解到,每个机器人对可行驶距离均有约束:除承载能力 cic_i 外,第 ii 个机器人还具有两个参数 fif_i 和 lil_i —— 分别表示移动该机器人所需的燃料量(单位:升)以及该机器人所能行驶的最大距离。

由于时间和燃料均十分有限,瓦列拉希望将尽可能多的机器人运送到行李舱。他采取如下操作方式:

  • 首先,瓦列拉选择一部分机器人,使其自行移动至行李舱;所有这些自行移动的机器人所需燃料总量不得超过 SS。
  • 然后,瓦列拉将剩余机器人装入已选机器人的舱室中,以实现尽可能多的机器人运输。注意:若某机器人不自行移动,则可将其放入另一个非自行移动的机器人舱室内,而该非自行移动机器人本身又由某个自行移动(或通过中间机器人间接由自行移动)的机器人所携带。
  • 此后,所有被选定并装载完毕的机器人,连同瓦列拉本人,一同前往行李舱;其余未被运输的机器人将被遗弃。

行李舱距当前位置 dd 米。因此,所有承担运输任务的机器人(即作为“载体”的机器人),其最大行驶距离 lil_i 必须不小于 dd。在运输过程中,瓦列拉无法中途停车,亦不可以任何方式调整机器人的位置。

请帮助瓦列拉计算他最多能带回家的机器人数量,以及为达成该目标所需的最少燃料消耗量(因为剩余燃料将在瓦列拉后续的研究中派上用场)。

输入格式

The first line contains three space-separated integers n, d, S (1 ≤ n ≤ 105, 1 ≤ d, S ≤ 109). 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 ≤ 109) — 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.

第一行包含三个以空格分隔的整数 nn、dd、SS(1 ≤ n ≤ 1051 \leq n \leq 10^5,1 ≤ d, S ≤ 1091 \leq d, S \leq 10^9)。第一个数表示机器人的数量,第二个数表示到行李舱的距离,第三个数表示可用的燃料总量。

接下来 nn 行描述各个机器人。第 ii 行包含三个以空格分隔的整数 cic_i、fif_i、lil_i(0 ≤ ci, fi, li ≤ 1090 \leq c_i, f_i, l_i \leq 10^9),表示第 ii 个机器人的各项参数:第一个数是第 ii 个机器人最多可携带的机器人数量,第二个数是第 ii 个机器人移动所需的燃料量,第三个数是第 ii 个机器人能行驶的最大距离。

输出格式

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.

输出两个用空格分隔的整数——Valera 能运送到行李舱的机器人的最大数量,以及实现该目标所需的最少燃料量。如果 Valera 无法将任何机器人运送到行李舱,则输出两个 0。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页