QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#2771. スピードを求めて

Statistics

Sheila は学生で、いかにも学生らしい車に乗っています。古くて遅く、さびていて、今にも壊れそうな車です。最近、スピードメーターの針が外れてしまいました。彼女は針を接着し直しましたが、取り付ける角度を間違えたかもしれません。そのため、スピードメーターが $s$ を示すとき、実際の速度は $s+c$ です。ここで $c$ は未知の定数で、負の値かもしれません。

problem_2771_5ba1e4d416c1e49ecad1d0b28eba330a.png

Sheila は最近のある旅について注意深く記録を取り、その記録を使って $c$ を求めたいと考えています。旅は $n$ 個の区間からなります。第 $i$ 区間では距離 $d_i$ を走り、その区間全体でスピードメーターは $s_i$ を示していました。旅全体にかかった時間は $t$ でした。Sheila のために $c$ を求めてください。

Sheila のスピードメーターは負の値を示すこともありますが、実際の速度は旅のどの区間でも零より大きかったことに注意してください。

入力

入力の最初の行には、Sheila の旅の区間数を表す整数 $n$($1 \le n \le 1\,000$)と、合計時間を表す整数 $t$($1 \le t \le 10^6$)が含まれます。続く $n$ 行は、それぞれ旅の一区間を記述します。そのうち第 $i$ 行には二つの整数 $d_i$($1 \le d_i \le 1\,000$)と $s_i$($|s_i| \le 1\,000$)が含まれ、第 $i$ 区間の距離とスピードメーターの表示値を表します。時間の単位は時間、距離の単位はマイル、速度の単位はマイル毎時です。

出力

定数 $c$ をマイル毎時で出力してください。解答の絶対誤差または相対誤差は $10^{-6}$ 未満でなければなりません。

入出力例

入力 1

3 5
4 -1
4 0
10 3

出力 1

3.000000000

入力 2

4 10
5 3
2 2
3 6
3 1

出力 2

-0.508653377

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.