编程介的小学生 2017-11-22 13:03 采纳率: 20.5%
浏览 597
已采纳

Sky Soldiers

Problem Description
An airplane carried k soldiers with parachute is plan to let these soldiers jump off the plane along a straight air route. The landing point of these soldiers is undetermined because of various weather conditions. However, the statisticians of the army can analysis the probability of landing in a certain place through landing history records. To make it simple, the statistician suggests that these sky soldiers will land on finite discrete points of a straight line.

This mission plans to place m provisions for the soldiers on the line for landing. These soldiers will be informed the direction of the nearest provision point by a special device after landing, and then walk to the point. The manager of this mission is asking you for help: to determine m points for provisions so that the expected sum of walking distance should be minimized. You can put provisions on any point of the landing line.

Input
There are multiple test cases. For each case, the first line contains two integers k and m (1 ≤ k ≤ 1,000, 1 ≤ m ≤ 50), which represent the number of sky soldiers and the number of positions to place provisions separately.

The following k lines contain descriptions of landing parameters for the soldiers numbered from 1 to k. Each description consists of an integer L followed by L pairs of (x, p), which indicates that the probability of the soldier's landing on integer coordination x is p. It is guaranteed that all the p values are positive real numbers, and the sum of p in a single line is exactly 1. The same x may appear more than once on the same line which you should simply add up all the probability p of the pairs with equal x.
The number of places on which all the soldiers could land is no more than 1000 and it can not be less than m.
The input ends with k=m=0.

Output
For each test case, output a line containing only one real number which indicates the minimum expected sum of distance these soldiers will move and should be rounded to two digits after the decimal point.

Sample Input
2 1
2 0 0.5 1 0.5
2 1 0.1 3 0.9
0 0

Sample Output
2.30

  • 写回答

1条回答 默认 最新

  • threenewbee 2018-07-26 15:18
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?