#P5485. [JLOI2010] 铁人双项比赛
[JLOI2010] 铁人双项比赛
Description
The Ironman Duathlon is a traditional sports event of Jilin Institute of Education. The race consists of long-distance running and cycling. Each contestant must first complete a -kilometer run, and then complete an -kilometer bike ride to reach the finish line. Different contestants are good at different events: some are better at running, while others are better at cycling. If the total distance is fixed, then the larger is, the more advantageous it is for contestants who are good at running; the smaller is, the more advantageous it is for contestants who are good at cycling.
Now you are given the total distance , as well as each contestant’s average speed for running and cycling. Please find the values of and that are the most favorable for a specified contestant. “Most favorable” means that after choosing this and , the contestant can win the championship, and the lead over the second place is as large as possible.
Input Format
Your program reads input from a file.
The first line contains two positive integers and . is the total distance (in kilometers, ), and is the total number of contestants ().
The next lines each contain two real numbers, representing each contestant’s average running speed and average cycling speed (in kilometers per hour).
The -th contestant is the specified contestant. Your task is to find the most favorable and for them.
Output Format
Your program should output three numbers , representing the most favorable and for contestant (floating-point numbers, rounded to decimal places), and the maximum number of seconds by which contestant can lead the second place under this choice of and (rounded to an integer). If another contestant ties with them for first place, then . If contestant cannot win no matter what and are chosen, output NO.
100 3
10.0 40.0
20.0 30.0
15.0 35.0
14.29 85.71 612
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号