Problem
Mikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool programmer, he needs at least p experience points, and a desired flat in Moscow costs q dollars. Mikhail is determined to follow his dreams and registered at a freelance site.
He has suggestions to work on n distinct projects. Mikhail has already evaluated that the participation in the i-th project will increase his experience by ai per day and bring bi dollars per day. As freelance work implies flexible working hours, Mikhail is free to stop working on one project at any time and start working on another project. Doing so, he receives the respective share of experience and money. Mikhail is only trying to become a cool programmer, so he is able to work only on one project at any moment of time.
Find the real value, equal to the minimum number of days Mikhail needs to make his dream come true.
For example, suppose Mikhail is suggested to work on three projects and a1 = 6, b1 = 2, a2 = 1, b2 = 3, a3 = 2, b3 = 6. Also, p = 20 andq = 20. In order to achieve his aims Mikhail has to work for 2.5 days on both first and third projects. Indeed,a1·2.5 + a2·0 + a3·2.5 = 6·2.5 + 1·0 + 2·2.5 = 20 and b1·2.5 + b2·0 + b3·2.5 = 2·2.5 + 3·0 + 6·2.5 = 20.
Input
The first line of the input contains three integers n, p and q (1 ≤ n ≤ 100 000, 1 ≤ p, q ≤ 1 000 000) — the number of projects and the required number of experience and money.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 1 000 000) — the daily increase in experience and daily income for working on the i-th project.
Output
Print a real value — the minimum number of days Mikhail needs to get the required amount of experience and money. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.
Namely: let’s assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if
.
Examples
input
| |
output
| |
input
| |
output
| |
Note
First sample corresponds to the example in the problem statement.
Solution
题目大意:一个人想要实现理想,实现理想需要\(p\)点经验和\(q\)点金钱。
现在他有\(n\)件事情要做,每件事情都有\(a_i\)的经验和\(b_i\)的金钱,现在他要实现自己的理想,问他需要做多少件事情?(事情可以做一部分,也就是说可以做事件的次数为一个实数)
和Codeforces 605 C是同一题,刷一赠一系列。
这道题我开始先考虑的线性规划,求出对偶问题来跑单纯型就可以了。但是…

搞不懂哪里有问题啊…骆学长说,单纯型操作只需要个位数就可以了,我就单纯的写了个单纯型…估计是第一次写写炸了…(不能怪萌萌哒骆学长[]~( ̄▽ ̄)~*…)
于是我放弃治疗了,看到题解给出一种凸包做法:

如图所示,我们就是把所有的事件放到坐标系中求个凸包,然后看凸包和\((p,q)\)的交点到原点距离\(dis\),用\((p,q)\)到原点的距离除以\(dis\)就是答案了。
注意:两个绿色的点是为了更好地构建凸包和统计对答案贡献用的,也就是说在事件中我们加入这两个事件就可以了。
这样做的证明方法蒟蒻想了半天,貌似相当于说对答案有用的事件也就两个,我们可以用这两个的“平均速度”来计算对答案的贡献。如果我们枚举的话是\(O(n^2)\)的,我们\(O(n {log} n)\)求出来凸包就可以做了。

虽然涉及实数运算,类型转换,但是感觉时间并没有高到哪里去。
Code
| |