QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#14863. Intermill Logistics

الإحصائيات

1825年9月25日。刚刚完成了创纪录的小麦丰收,你正琢磨着该如何处理这些小麦。灵光一闪,你决定用所有这些小麦来烘焙你最喜欢的饼干:荷式松饼(stroopwafels)。当然,所有这些小麦都必须先磨成面粉。因为你迫不及待地想开始烘焙,你想尽可能快地完成这件事,所以你决定联系荷兰所有的面粉厂寻求帮助。

其中一家面粉厂。

对于这些面粉厂中的每一家,你都知道它们将小麦磨成面粉的速度,以及运送货物往返该面粉厂所需的时间。你有足够多的运粮船,可以将小麦运送到这些面粉厂,并将面粉运回。如果在这几家面粉厂之间最优地分配小麦,那么从开始到你收回所有小麦需要多长时间?

作为一个例子,考虑第一个样例。为了在三家面粉厂之间最优地分配小麦,你向第一家运送 400 千克,向第二家运送 120 千克,向第三家运送 480 千克。第一家面粉厂需要 5 小时来磨它的小麦,第二家需要 1 小时,第三家需要 3 小时。结合往返每家面粉厂的运输时间,你恰好在 11 小时后收回所有小麦。

在第二个样例中,我们将所有的小麦都送到第一家面粉厂。这家面粉厂可以在 1 小时内磨完所有 100 千克的小麦,加上往返运输的 2 小时,总共需要 3 小时。由于第二家面粉厂的运输时间就已经需要 4 小时,因此仅使用第一家面粉厂是最优的。

输入格式

输入包含以下内容:

  • 第一行包含两个整数 $n$ 和 $w$($1 \le n \le 10^5$,$1 \le w \le 10^9$),分别表示面粉厂的数量和你的小麦总量(单位:千克)。
  • 接下来 $n$ 行,每行包含两个整数 $p$ 和 $t$($1 \le p, t \le 10^9$),描述一家面粉厂:它每小时可以处理 $p$ 千克小麦,且单程距离为 $t$ 小时。

输出格式

输出在最优分配小麦的情况下,直到你收回所有小麦所需的小时数。

你的答案与标准答案的绝对误差或相对误差应不超过 $10^{-6}$。

样例

输入样例 1

3 1000
80 3
120 5
160 4

输出样例 1

11

输入样例 2

2 100
100 1
500 2

输出样例 2

3

输入样例 3

3 7
1 1
1 1
1 1

输出样例 3

4.3333333

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.