|
||||||||||
Running relayTime Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1770 Accepted Submission(s): 448 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
Sample Output
Hint In the first case, the first member runs 10.5 meters and the second member runs 9.5 meters. S=8¡Á10.5+6¡Á9.5=141=W, T=3¡Á10.5+6¡Á9.5=88.5. In the second case, every member should run at least 8 meters. But the length of the track is only 20 meters. Because 8¡Á3>20, there is no solution. Source | ||||||||||
|