CF3B.Lorry

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:64MB

AC君温馨提醒

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

题目描述

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.

一群游客将参加皮划艇和双体船游览。一辆租来的卡车已抵达船坞,准备将皮划艇和双体船运送到出发地点。已知所有皮划艇尺寸相同(每艘占据 1 立方米空间),而所有双体船尺寸也相同,但体积是皮划艇的两倍(每艘占据 2 立方米空间)。

每艘水上载具均有特定的载重能力;需注意:外观相同的水上载具,其载重能力可能不同。已知卡车货厢的总体积,以及船坞中所有水上载具的清单(对每一艘载具,均已知其类型及载重能力),请找出一组可装入该卡车的水上载具,使其总载重能力最大。卡车货厢空间可被充分利用,即:只要某艘水上载具所占体积不超过货厢当前剩余空间,就总能将其装入货厢。

输入格式

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 t__i, p__i (1 ≤ t__i ≤ 2; 1 ≤ p__i ≤ 104), where t__i is the vehicle type (1 – a kayak, 2 – a catamaran), and p__i is its carrying capacity. The waterborne vehicles are enumerated in order of their appearance in the input file.

第一行包含两个整数 nn 和 vv(1 ≤ n ≤ 1051 ≤ n ≤ 10^5;1 ≤ v ≤ 1091 ≤ v ≤ 10^9),其中 nn 表示船坞中水运载具的数量,vv 表示卡车货厢的体积(单位:立方米)。接下来的 nn 行描述了这些水运载具的信息,每行包含一对整数 ti, pit_i,\,p_i(1 ≤ ti ≤ 21 ≤ t_i ≤ 2;1 ≤ pi ≤ 1041 ≤ p_i ≤ 10^4),其中 tit_i 表示载具类型(1 — 皮划艇,2 — 双体船),pip_i 表示其载重能力。水运载具按其在输入文件中出现的顺序编号。

输出格式

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.

第一行输出该集合的最大可能承载能力。
第二行输出一个字符串,包含构成最优集合的车辆编号。若答案不唯一,输出任意一个即可。

输入输出样例

  • 输入#1

    3 2
    1 2
    2 7
    1 3

    输出#1

    7
    2

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

首页