102232: [AtCoder]ABC223 C - Doukasen

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:9 Solved:0

Description

Score : $300$ points

Problem Statement

We have $N$ fuses connected in series. The $i$-th fuse from the left has a length of $A_i$ centimeters and burns at a constant speed of $B_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

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

Input

Input is given from Standard Input in the following format:

$N$
$A_1$ $B_1$
$A_2$ $B_2$
$\vdots$
$A_N$ $B_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 $10^{-5}$.


Sample Input 1

3
1 1
2 1
3 1

Sample Output 1

3.000000000000000

The two flames will meet at $3$ 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

Input

题意翻译

有 $n$ 根香,第 $i$ 根香长度为 $a_i$ 厘米。现在所有香按照他们的编号( $i$ )从左至右首尾相连地排成一条直线。已知若第 $i$ 根香从一头点着,每秒会燃烧 $b_i$ 厘米。现在,同时点着由这 $n$ 根香组成的这条直线的左右两端,问:所有香都燃尽时,两边的火苗会在直线左起几厘米处相会?

Output

得分:300分

问题描述

我们有$N$个串联连接的引信。从左边数的第$i$个引信的长度为$A_i$厘米,燃烧速度为$B_i$厘米/秒。

考虑从左右两端同时点燃这个物体。找出两火焰相遇的位置与物体左端的距离。

限制条件

  • $1 \leq N \leq 10^5$
  • $1 \leq A_i,B_i \leq 1000$
  • 输入中的所有值都是整数。

输入

输入将以以下格式从标准输入给出:

$N$
$A_1$ $B_1$
$A_2$ $B_2$
$\vdots$
$A_N$ $B_N$

输出

以厘米为单位打印两火焰相遇的位置与物体左端的距离(只打印数字)。

当您的输出与我们的答案的绝对误差或相对误差不超过$10^{-5}$时,将被视为正确。


样例输入1

3
1 1
2 1
3 1

样例输出1

3.000000000000000

两火焰将在距离物体左端$3$厘米的位置相遇。


样例输入2

3
1 3
2 2
3 1

样例输出2

3.833333333333333

样例输入3

5
3 9
1 2
4 6
1 5
5 3

样例输出3

8.916666666666668

加入题单

算法标签: