博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
暑假练习赛 003 B Chris and Road
阅读量:6945 次
发布时间:2019-06-27

本文共 3761 字,大约阅读时间需要 12 分钟。

B - Chris and Road

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

Submit
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 
# include
# include
# include
# include
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
m_v; for(int i = 0; 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 = 1, ok2 = 1; double t = 0; for(int i = 0; i < m_v.size(); i++) { if (m_v[i].x / v > m_v[i].y / u) ok1 = 0; if (m_v[i].x / v < m_v[i].y / u) ok2 = 0; 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 0;}

 

转载于:https://www.cnblogs.com/wuwangchuxin0924/p/5754693.html

你可能感兴趣的文章
R语言学习 第二篇:矩阵和数组
查看>>
在服务器端png转jpg
查看>>
MarkDown 编辑数学公式
查看>>
Docker(五):Docker 三剑客之 Docker Machine
查看>>
SQLite中的WHERE子句
查看>>
移动端底部input被弹出的键盘遮挡
查看>>
dubbo 部分 配置的关系-dubbo github 官方案例
查看>>
SpringBoot JMS(ActiveMQ) 使用实践
查看>>
如何用Tensorflow训练模型成pb文件和和如何加载已经训练好的模型文件
查看>>
Mysql系列九:使用zookeeper管理远程Mycat配置文件、Mycat监控、Mycat数据迁移(扩容)...
查看>>
『转载』使用DotMSN 2.0开发MSN机器人
查看>>
1489: 数字排列 (DFS)
查看>>
china-pub满48元即刻享受免运费
查看>>
分布式系统工程实现:GFS&amp;Bigtable设计的优势,互联网营销
查看>>
用WPF实现屏幕文字提示,徐汇区网站设计
查看>>
在tomcat中配置连接池
查看>>
矩阵乘法-并行计算
查看>>
EF 增删改查 泛型方法、类
查看>>
Android 中的MVP 模式
查看>>
SQL函数说明大全
查看>>