#abc223c. C - Doukasen

C - Doukasen

Score : 300300 points

问题描述

我们有 NN 个保险丝串联连接。从左边数第 ii 个保险丝的长度为 AiA_i 厘米,且其燃烧速度为常数,每秒燃烧 BiB_i 厘米。

假设我们同时从该物体的左右两端点燃,请找出两个火焰相遇位置与物体左端的距离。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

We have NN fuses connected in series. The ii-th fuse from the left has a length of AiA_i centimeters and burns at a constant speed of BiB_i centimeters per second.

Consider igniting this object from left and right ends simultaneously. Find the distance between the position where the two flames will meet and the left end of the object.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 1Ai,Bi10001 \leq A_i,B_i \leq 1000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 B1B_1

A2A_2 B2B_2

\vdots

ANA_N BNB_N

Output

Print the distance between the position where the two flames will meet and the left end of the object, in centimeters (print just the number).

Your output will be considered correct when its absolute or relative error from our answer is at most 10510^{-5}.

Sample Input 1

3
1 1
2 1
3 1

Sample Output 1

3.000000000000000

The two flames will meet at 33 centimeters from the left end of the object.

Sample Input 2

3
1 3
2 2
3 1

Sample Output 2

3.833333333333333

Sample Input 3

5
3 9
1 2
4 6
1 5
5 3

Sample Output 3

8.916666666666668

update @ 2024/3/10 09:49:19