time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

And while Mishka is enjoying her trip…

Chris is a little brown bear. No one knows, where and when he met Mishka, but for a long time they are together (excluding her current trip). However, best friends are important too. John is Chris’ best friend.

Once walking with his friend, John gave Chris the following problem:

At the infinite horizontal road of width w, bounded by lines y = 0 and y = w, there is a bus moving, presented as a convex polygon of n vertices. The bus moves continuously with a constant speed of v in a straight Ox line in direction of decreasing x coordinates, thus in time only x coordinates of its points are changing. Formally, after time t each of x coordinates of its points will be decreased by vt.

There is a pedestrian in the point (0, 0), who can move only by a vertical pedestrian crossing, presented as a segment connecting points (0, 0) and (0, w) with any speed not exceeding u. Thus the pedestrian can move only in a straight line Oy in any direction with any speed not exceeding u and not leaving the road borders. The pedestrian can instantly change his speed, thus, for example, he can stop instantly.

Please look at the sample note picture for better understanding.

We consider the pedestrian is hit by the bus, if at any moment the point he is located in lies strictly inside the bus polygon (this means that if the point lies on the polygon vertex or on its edge, the pedestrian is not hit by the bus).

You are given the bus position at the moment 0. Please help Chris determine minimum amount of time the pedestrian needs to cross the road and reach the point (0, w) and not to be hit by the bus.

Input

The first line of the input contains four integers n, w, v, u (3 ≤ n ≤ 10 000, 1 ≤ w ≤ 109, 1 ≤ v,  u ≤ 1000) — the number of the bus polygon vertices, road width, bus speed and pedestrian speed respectively.

The next n lines describes polygon vertices in counter-clockwise order. i-th of them contains pair of integers xi and yi ( - 109 ≤ xi ≤ 109, 0 ≤ yi ≤ w) — coordinates of i-th polygon point. It is guaranteed that the polygon is non-degenerate.

Output

Print the single real t — the time the pedestrian needs to croos the road and not to be hit by the bus. The answer is considered correct if its relative or absolute error doesn’t exceed 10 - 6.

Example

input

5 5 1 2

1 2

3 1

4 3

3 4

1 4

output

5.0000000000

Note

Following image describes initial position in the first sample case:

【题解】



题意:你要从(0,0)走到(0,w),右方有一部多边形的车从右往左走过来;你要花最少的时间走到(0,w),且不被车撞。

做法:

对于所有的点。获取->当你和车上的这个点(px,py)的坐标的纵坐标相同的时候,车上的这个点的横坐标为多少;

设你和这个点的纵坐标相同时所花的时间为t=py/u

则车上这个点的横坐标px’变为px-t*v

获取车上的所有点的px’中的max和min值

分类讨论:

1.最简单的。就是直接高速走过去都不会被车撞->即到达(0,0)->(0,w)这条线段上的所有点的时候。车子的所有点都在你到达之前就全都走过了。或者全都还没到达.

->对应min >=0 || (min <0 && max <=0)的情况

答案当然就是w/u了

2.可能会被撞.

即min <0 but max >0

就需要减速了。

需要怎么减速呢?我们把它理解为停顿一下;



对于我们求出来的max,它对应上图的情况。(车子从右往左移动对应人从左下往左上);

即我们全速前进和从下往上数第二个波峰的纵坐标相同的时候.横坐标的差值.因为这个差值的存在,所以我们会被车撞。

当前第一个波峰的时候也会被车撞。

但是显然第二个波峰造成的影响需要修正的地方更大;

那么要怎么修正呢?

首先我们可以确定。我们到达第二个波峰的时候(虽然会被撞)但是时间是最短的。因为是全速前进的。

那么我们想保留这个最快的过程应该要怎么样呢.

这样理解:



即把这条线段往右平移一段。这样我们全速前进到和第二个波峰的纵坐标相同的时候。刚好碰到那个波峰(题目设定这样不算被撞)。到了波峰之后只要全速前进就可以到终点了。

那这个平移代表什么呢?

当然就是在起点等了一段时间->max/v



所以总的时间就是

max/v+w/u;

这里你们可能会想到:那第一个波峰呢?



实际上我们是不会碰到第一个波峰的。因为我们在处理的时候已经知道AB这段长度max是大于d1的了。

而我们和W和B点的纵坐标相同的时候,经过的点分别是Q和A

如果我们向右平移了max个单位。max>d1则肯定我们走平移过的路线之后和W的纵坐标相同的时候,肯定是在W的右边的.也就是说W这个点肯定已经走到x=0的左边去了。

多想想吧.

可能有人会想到这种情况。



这样不就不对了吗???

但是注意车的点的纵坐标是大于0的!

所以图中的A点是不合法的.

再多说几句吧:

设max对应的点,即倒数第二张图的B点。

我们肯定是要到那个坐标的;

而我们得知到那个坐标之后你得等那个B点从你身前走过去,而你是全速前进的,所以到达B点的最短时间肯定就是yb/u了但是你得等这个B点走过去;这又是不得不等的一段时间;所以我们干脆就在起点等这段时间过去,然后马上以最高时速到达这个B点,这样肯定满足时间最短,且这个B点刚好走到左边去了,过后就是康庄大道了。可以一直以高速前进.

综上这个方法是可行的。

别想了,我的脑子。就是这样了。睡觉吧。

(博主是强迫症患者TAT)

#include <cstdio>
#include <algorithm> using namespace std; const double INF = 1e15;
int n;
double w, v, u;
double mi=INF, ma = 0,ans; int main()
{
scanf("%d%lf%lf%lf", &n, &w, &v, &u);
for (int i = 1; i <= n; i++)
{
int x, y;
scanf("%d%d", &x, &y);
double dis = x - y/u*v;
ma = max(ma, dis);
mi = min(mi, dis);
}
if (mi >= 0)
ans = w / u;
else//mi <0
if (ma<= 0)
ans = w / u;
else//ma > 0
ans = ma / v + w / u;
printf("%.10lf\n", ans);
return 0;
}

【23.15%】【codeforces 703C】Chris and Road的更多相关文章

  1. 【 BowWow and the Timetable CodeForces - 1204A 】【思维】

    题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...

  2. 【23. 合并K个排序链表】【困难】【优先队列/堆排序】

    合并 k 个排序链表,返回合并后的排序链表.请分析和描述算法的复杂度. 示例: 输入: [ 1->4->5, 1->3->4, 2->6] 输出: 1->1-> ...

  3. 【20.23%】【codeforces 740A】Alyona and copybooks

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 【23.33%】【codeforces 557B】Pasha and Tea

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【23.39%】【codeforces 558C】Amr and Chemistry

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. 【15.07%】【codeforces 625A】Guest From the Past

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  7. 【30.23%】【codeforces 552C】Vanya and Scales

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. 【16.23%】【codeforces 586C】Gennady the Dentist

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  9. 【23.26%】【codeforces 747D】Winter Is Coming

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

随机推荐

  1. windows下安装wabt

    windows下安装wabt 安装前准备cmake.mingw环境 安装cmake 安装mingw 步骤 # 1.克隆wabt源码 git clone https://github.com/WebAs ...

  2. java三大特性:封装、继承、多态

    Java三大特性之封装   一.定义 封装性指的是将对象的状态信息隐藏在对象内部,不允许外部程序直接访问对象内部的信息,而是通过该类所提供的方法来实现对内部信息的操作和访问. 二.使用封装的好处: 1 ...

  3. OAuth2 社区通用组件

    转载:http://www.cyqdata.com/download/article-detail-54302   使用本组件,只需要几行代码,就可以在网站上集成以下效果:     相关文章及使用说明 ...

  4. apache-spark导入eclipse环境

    工作中用到了apache-spark,想深入了解一下,决定从源码开始. 先导入到常用的ide,eclipse吧: 准备工作 1.  下载Eclipse:http://scala-ide.org/ 2. ...

  5. zynq mac地址修改

    工作中遇到多个zynq板子同时位于一个交换机网络中,由于默认mac地址相同,无法进行通信,因此需要对每个板子修改mac地址. 方案:使用uboot配置文件 步骤: 在uboot配置文件中添加及修改下面 ...

  6. AE开发技术文档--8种数据访问方法

    转自原文 AE开发技术文档--8种数据访问方法 1.shapefile IWorkspaceFactory pWorkspaceFactory; pWorkspaceFactory = new Sha ...

  7. IQMath是什么 浮点转定点运算,dsp

    [转帖注明出处:blog.csdn.net/lanmanck] 网上搜了一下没发现非常合适的,特写出来与大家分享. 大家都知道嵌入式系统里带浮点运算指令的CPU都比較少,TI的DSP也是定点的廉价. ...

  8. anaconda中实现双spyder版本

    1)先在conda中创建一个名为python2的环境,并下载对应版本python2.7 conda create --name python27 python=2.7 2)激活python2环境 ac ...

  9. MFC屏蔽 WindowS按键

    LRESULT CALLBACK LowLevelKeyboardPorc(int nCode,WPARAM wParam,LPARAM lParam)//屏蔽按键的真正实现方法{ BOOL fEat ...

  10. 特殊类型数据:IP地址字段(IPv4)

    人们经常使用varchar(15)来存储ip地址,然而,它们实际上是32位无符号整数,不是字符串. MySQL提供INET_ATON()和INET_NTOA()函数将ip地址在整数和四段表示形式之间进 ...