编程介的小学生 2020-01-17 21:47 采纳率: 20.5%
浏览 66

Running relay 的实现

Problem Description
The school track-and-field team is taking a running relay race. There are n (2<=n<=104) members in the team. In order to let everybody participate in the race, each member should run at least d (0<=d<=10) meters. Besides that, everyone can run arbitrary distance. The whole length of the track is L (1<=L<=105) meters.

For the ith member in the team, if he is in a good mood, then it takes him ti seconds (1<=ti<=4×104) to run one meter. If he is in a bad mood, then it takes him si (1<=si<=4×104, 1<=ti<=si) seconds to run one meter.

As the coach of the team, you can assign the running distance of each member in advance. Suppose that, it takes S seconds for the team to complete the relay race if all the members are in bad moods and it takes T seconds for the team to complete the relay race if all the members are in good moods. You do want to have a good score. But you don’t want to have a very bad score even if someone is in a bad mood. So you want to know the minimum value of T on condition that S should not be larger than W (1<=W<=2147483647).

Input
The input begins with a line containing an integer, indicating the number of test cases. There are no more than 100 test cases.

For each case, the first line begins with four integers --- the above mentioned n, d, L and W. Then n lines follow, each representing a member. Each line contains two integers s and t, meaning that the member spends s seconds to run one meter when he/she is in a bad mood, and spends t seconds to run one meter when he/she is in a good mood.

Output
For each test case, if you cannot find a proper way to assign the running distance of each member, output a string “No solution” in a line. Otherwise, output the minimum value of T (rounded to 2 digits after the decimal point) in a line.

Sample Input
2
2 1 20 141
8 3
6 6
3 8 20 200
8 3
6 6
7 1

Sample Output
88.50
No solution

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料