QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#24361. Bicycle Race

Statistics

At a certain moment, called the initial moment, the cyclists taking part in a road race are at distances of $x_1,x_2,\ldots,x_n$ meters from the starting point ($n$ is the total number of cyclists). Each cyclist moves at their own constant speed of $v_1,v_2,\ldots,v_n$ meters per second. All cyclists move in the same direction.

A reporter covering the competition wants to determine the moment when the distance between the leading cyclist and the last cyclist becomes minimal, in order to photograph all the participants in the bicycle race at once from a helicopter.

Write a program that, given the number of cyclists $n$, their initial positions $x_1,x_2,\ldots,x_n$, and their speeds $v_1,v_2,\ldots,v_n$, computes a time $t$ when the distance $l$ between the leading and last cyclists is minimal.

Input

The first line of the input file contains an integer $n$, the number of cyclists.

The next $n$ lines each contain two integers: $x_i$, the distance from the starting point to cyclist $i$ at the initial moment ($0\le x_i\le10^7$), and $v_i$, their speed ($0\le v_i\le10^7$).

Output

Output two real numbers to the output file: $t$, the time in seconds elapsed from the initial moment until the distance in meters between the leader and the last cyclist is minimal, and $l$, that distance.

The numbers $t$ and $l$ must have an absolute or relative error of at most $10^{-6}$, which means the following. Let the printed number be $x$ and the correct answer be $y$. The answer is considered correct if $|x-y|/\max\{1,|y|\}$ does not exceed $10^{-6}$.

Examples

Input 1

3
0 40
30 10
40 30

Output 1

1 30

Input 2

5
90 100
100 70
100 70
110 60
120 35

Output 2

0.5 5.000000000000

Subtasks

This problem has four subtasks. A separate group of tests is used to grade each subtask. Points for a subtask are awarded only if all tests in that group are passed.

Subtask 1 (20 points)

$2\le n\le50$, $0\le x_i\le1000$, $0\le v_i\le1000$. It is guaranteed that an answer exists in which $t$ is an integer not exceeding $1000$.

Subtask 2 (20 points)

$2\le n\le200$.

Subtask 3 (30 points)

$2\le n\le2000$.

Subtask 4 (30 points)

$2\le n\le10^5$.

Feedback

During the round, you may request the results of your program on the jury tests at most 10 times. Requests may be made no more often than once every 5 minutes. For each test, the result of running the program on that test is reported.

In this problem, you may choose which solution will be graded. In that case, the score is awarded for the better of the following solutions:

  • the explicitly selected solution;
  • the last solution accepted for judging.

If no selection is made, the best of the following solutions will be graded:

  • the solutions for which the scores have been viewed;
  • the last solution accepted for judging.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.