1.24 Lorry

https://acs.jxnu.edu.cn/problem/CF3B1.24 Lorryhttps://acs.jxnu.edu.cn/problem/CF3B

A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times bigger than kayaks (and occupy the space of 2 cubic metres).

一组游客要去皮划艇和双体船旅游。一辆租来的货车已经到达船库,将皮划艇和双体船带到出发点。已知所有皮划艇都是同等大小(每个占据1立方米),而且所有的双体船都是同等大小,但是是皮划艇的两倍(每个占据2立方米)。

Each waterborne vehicle has a particular carrying capacity, and it should be noted that waterborne vehicles that look the same can have different carrying capacities. Knowing the truck body volume and the list of waterborne vehicles in the boat depot (for each one its type and carrying capacity are known), find out such set of vehicles that can be taken in the lorry, and that has the maximum total carrying capacity. The truck body volume of the lorry can be used effectively, that is to say you can always put into the lorry a waterborne vehicle that occupies the space not exceeding the free space left in the truck body.

每辆水上交通工具都有特定的承载能力,需要注意的是即使看起来相同的水上交通工具也有不同的承载能力。了解卡车车身的体积以及船库中的水上车辆体积(每个车辆的类型和承载能力是已知的),找出可以装在卡车上并且具有最大总承载能力的此类车辆。可以有效利用货车的车体容积,这意味着你可以将水上运输工具装进货车,可以占据货车空间而不溢出也没有空余的空间。

输入:

The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 104), where ti is the vehicle type (1 – a kayak, 2 – a catamaran), and pi is its carrying capacity. The waterborne vehicles are enumerated in order of their appearance in the input file.

第一行包括2个整数n和v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109),n表示在船库的水上交通工具的数量,v是用立方米表示的货车的容量。接下来n行包括水上运输工具的信息,用两个数字ti和pi表示 (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 104),其中 ti 是车辆类型(1 – 皮划艇,2 – 双体船),pi 是其承载能力。水上交通工具按照它们在输入文件中出现的顺序进行列举。

输出:

In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.

在第一行输出车辆的最大承载能力。在第二行输出一个字符串包含能够构成最佳集合的车辆数量组成。如果答案不唯一,输出任意一组数据。

样例输入:

3 2
1 2
2 7
1 3

样例输出:

7
2
上一篇:P5207 [WC2019] 远古计算机 - 提交答案,图论


下一篇:[洛谷1119]灾后重建