描述:
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).
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.
输出:
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
描述:
一群游客要去皮划艇和双体船旅行。一辆租来的用来将皮划艇和双体船运往出发地的卡车已经到达了船坞。众所周知,所有的皮划艇都是一样大小的(每一个都占据1立方米的空间),所有的双体船大小相同,但比皮划艇大两倍(占据2立方米的空间)。
每一种水上交通工具都有其特定的承载能力,需要注意的是,外观相同的水上交通工具可能具有不同的承载能力。了解船坞载货汽车的车体体积和水上交通工具的清单(对于每一种,其类型和承载能力是已知的),找出卡车可装载的并且总载重量最大的车辆组。卡车的车身容积可以被有效地利用,也就是说,你可以在卡车上放置一种水上交通工具,它所占用的空间不超过卡车车身的剩余空间。
输入:
第一行包括一对整数n和v(1 ≤ n ≤ 105; 1 ≤ v ≤ 109),n是船坞上水上交通工具的数量,v是以立方米为单位的卡车的车体体积。接下来的n行包括水上交通工具的有关信息,一对数字ti ,pi(1 ≤ ti ≤ 2; 1 ≤ pi ≤ 104),ti是车辆类型(1代表一辆皮划艇,2代表一辆双体船),pi是它的承载能力。水上交通工具按其在输入文件中出现的顺序被一一列举。
输出:
第一行输出最大可能的承载能力的选择,第二行输出一个由构成最佳选择的车辆数量组成的字符。如果答案不唯一,输出任意一个即可。
样例输入:
3 2 1 2 2 7 1 3
样例输出:
7 2
题目地址链接:Problem - B - Codeforces