编程介的小学生 2017-05-14 04:43 采纳率: 20.5%
浏览 869
已采纳

RPG

Description

To complete a role-playing game (RPG), you must send your character through N quests. The quests may be passed in any order, but after starting a quest you can’t drop it and switch to another. If your character fails even one quest you fail the whole game. The probability of succeeding in a quest depends on the experience points (XP) of your character at the beginning of the quest, and is determined by the formula
where ai and bi are parameters of the i-th quest.
After successful completion of the i-th quest, your character obtains Si experience points. Initially, it/he/she has D points.

Write a program to determine such an order of the quests that the probability of completing the whole game successfully is the highest possible.

Input

The first line of the input contains the values N (1≤N≤10) and D. Each of the following N lines describes one quest, containing the values ai, bi, Si. The values D, ai, bi, Si (1≤i≤N) are all integers in the range from 0 to 1000 and ai<bi (1≤i≤N). Adjacent values on the same line are separated by one or more spaces.

Output

The first line of the output must contain the highest possible probability with the precision of 0.001. The second line must contain the order of quests that ensures this probability. If there are several orders with the same probability, output any one of them.

Sample Input

3 300
350 380 100
100 200 100
440 450 100
Sample Output

1.000
2 1 3

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-05-31 02:59
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效