B - Chris and Road

Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit Status Practice _ uDebug

Description

 

Input

 

Output

 

Sample Input

 

Sample Output

 

Hint

 

Description

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.

Sample Input

 

Input
5 5 1 2
1 2
3 1
4 3
3 4
1 4
Output
5.0000000000

Sample Output

 

Hint

Following image describes initial position in the first sample case:

/*
赛后除了F题才想这个B题的,被A题坑死了
先判断一下是否能在车来之前就过去,不能的话就按着最右边的点走
第二种情况很简单,只需要先按照y坐标排序,按照时间的顺序走x就行了
*/
# include <iostream>
# include <stdio.h>
# include <vector>
# include <algorithm>
# include <cstdio>
using namespace std;
struct Point
{
double x;
double y;
};
bool cmp(Point a, Point b)
{
if(a.y != b.y)
return a.y < b.y;
return a.x < b.x;
}
int main()
{
double n, w, v, u;
while(scanf("%lf%lf%lf%lf",&n,&w,&v,&u)!=EOF)
{
vector <Point> m_v;
for(int i = ; i < n; i++)
{
Point p;
scanf("%lf%lf",&p.x,&p.y);
m_v.push_back(p);
}
sort(m_v.begin(), m_v.end(), cmp);
bool ok1 = , ok2 = ;
double t = ;
for(int i = ; i < m_v.size(); i++)
{
if (m_v[i].x / v > m_v[i].y / u)
ok1 = ;
if (m_v[i].x / v < m_v[i].y / u)
ok2 = ;
t = max(t, m_v[i].x / v + (w - m_v[i].y) / u);
}
if(ok1 || ok2)
printf("%.10lf\n", w / u);
else
printf("%.10lf\n", t);
}
return ;
}

暑假练习赛 003 B Chris and Road的更多相关文章

  1. 暑假练习赛 003 F Mishka and trip

    F - Mishka and trip Sample Output   Hint In the first sample test: In Peter's first test, there's on ...

  2. 暑假练习赛 003 A Spider Man

    A - Spider Man Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144KB    ...

  3. Codeforces Round #365 (Div. 2) Chris and Road

    Chris and Road 题意: 给一个n个顶点的多边形的车,有速度v,人从0走到对面的w,人速度u,问人最快到w的时间是多少,车如果挡到人,人就不能走. 题解: 这题当时以为计算几何,所以就没做 ...

  4. Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点

    // Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停 ...

  5. cf703C Chris and Road

    C. Chris and Road time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  6. 【23.15%】【codeforces 703C】Chris and Road

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. CodeForces 703C Chris and Road

    数学,递推. 不知道有没有更加神奇的做法,我是这样想的: 首先,如果多边形完全在$y$轴左侧,那么答案为$\frac{w}{u}$. 剩下的情况就要先判断是否能在车开过之前跑过去,如果跑不过去,要在车 ...

  8. 暑假练习赛 007 E - Pairs

    E - Pairs Description standard input/outputStatements In the secret book of ACM, it’s said: “Glory f ...

  9. 暑假练习赛 007 C - OCR

    C - OCR Description standard input/outputStatements Optical Character Recognition (OCR) is one of th ...

随机推荐

  1. Opengl4.5 中文手册—F

    索引 A      B    C      D     E     F     G H      I     J      K     L     M     N O      P    Q      ...

  2. ios小型服务器环境配置

    之前买的一台二手iphone4退役了,上闲鱼上一看,就值200,而且耳机声音也有点轻,估计买不了什么钱 于是网上看看能不能有什么废物利用的法子,看到说做行车记录仪的,有说做git服务器的,感觉挺有兴趣 ...

  3. SSM之整合Redis

    Redis安装与使用 第一步当然是安装Redis,这里以Windows上的安装为例. 首先下载Redis,可以选择msi或zip包安装方式 zip方式需打开cmd窗口,在解压后的目录下运行redis- ...

  4. 51nod 1451 合法三角形 判斜率去重,时间复杂度O(n^2)

    题目: 这题我WA了3次,那3次是用向量求角度去重算的,不知道错在哪了,不得不换思路. 第4次用斜率去重一次就过了. 注意:n定义成long long,不然求C(3,n)时会溢出. 代码: #incl ...

  5. Hadoop 2:Mapper和Reduce

    Hadoop 2:Mapper和Reduce Understanding and Practicing Hadoop Mapper and Reduce 1 Mapper过程 Hadoop将输入数据划 ...

  6. 快速双边滤波 附完整C代码

    很早之前写过<双边滤波算法的简易实现bilateralFilter>. 当时学习参考的代码来自cuda的样例. 相关代码可以参阅: https://github.com/johng12/c ...

  7. FastDFS的安装步骤

    1.安装相关环境 yum install -y gcc-c++ yum -y install libevent yum install -y pcre pcre-devel yum install - ...

  8. Block使用的简单总结

    一.Block简单的使用 1.block当作参数来传递 如下定义一个没有返回值无参数的block,并把它作为参数,让系统调用,注意:这里是系统在调用,不是我们调用 那么为什么需要把block当作参数去 ...

  9. Python实战之Selenium自动化测试web登录

    #!/usr/bin/env python3 # -*- coding:utf-8 -*- from selenium import webdriver from selenium.webdriver ...

  10. windows2008(64位)下iis7.5中的url伪静态化重写(urlrewrite)

    以前在windows2003里,使用的是iis6.0,那时常使用的URL重写组件是iisrewrite,当服务器升级到windows2008R2时,IIS成了64位的7.5,结果iisreite组件是 ...