编程介的小学生 2019-03-12 21:38 采纳率: 20.5%
浏览 215

组合问题的难度的控制算法,采用C语言编程的实现的方式

Problem Description
LL is very sensitive to the difficulty of ACM problems. He can assign each problem a positive integer from [1,10000000] to denote its difficulty ( although he has only ACed about 1000 problems ^_^ ). Now, there are N problems in his mind. He want to choose some of them to hold a contest and the total difficulty of all problems in the contest is as near as possible to M.

Input
For each case, the first line is two positive integers N and M (1<=N<=26). Followed by N lines. Each line contains the problem's ID ( a single capital letter ) and its difficulty.

Output
For each case, ouput how many and which problems he should choose in the format of the sample. If more than one combinations of problems reach the request, output the one which comes earliest in lexicography order.

Sample Input
3 10
A 4
B 12
C 8

Sample Output
2
A C

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度
    • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
    • ¥15 再不同版本的系统上,TCP传输速度不一致
    • ¥15 高德地图点聚合中Marker的位置无法实时更新
    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿