编程介的小学生 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 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services