暑假练习赛 003 B Chris and Road
Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
uDebugDescription
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
5 5 1 2
1 2
3 1
4 3
3 4
1 4
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的更多相关文章
- 暑假练习赛 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 ...
- 暑假练习赛 003 A Spider Man
A - Spider Man Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144KB ...
- Codeforces Round #365 (Div. 2) Chris and Road
Chris and Road 题意: 给一个n个顶点的多边形的车,有速度v,人从0走到对面的w,人速度u,问人最快到w的时间是多少,车如果挡到人,人就不能走. 题解: 这题当时以为计算几何,所以就没做 ...
- Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点
// Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停 ...
- cf703C Chris and Road
C. Chris and Road time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- 【23.15%】【codeforces 703C】Chris and Road
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- CodeForces 703C Chris and Road
数学,递推. 不知道有没有更加神奇的做法,我是这样想的: 首先,如果多边形完全在$y$轴左侧,那么答案为$\frac{w}{u}$. 剩下的情况就要先判断是否能在车开过之前跑过去,如果跑不过去,要在车 ...
- 暑假练习赛 007 E - Pairs
E - Pairs Description standard input/outputStatements In the secret book of ACM, it’s said: “Glory f ...
- 暑假练习赛 007 C - OCR
C - OCR Description standard input/outputStatements Optical Character Recognition (OCR) is one of th ...
随机推荐
- #pragma编译指令
#pragma alignment#pragma anon_struct#pragma argsused#pragma checkoption#pragma codeseg#pragma commen ...
- CentOS7 +vsftpd (一)之 匿名
CentOS7 +vsftpd (一)之 匿名 ftp的搭建是一个基础性的工作,CentOS7 +vsftpd 是一个比较容易实现的平台,但在搭建中问题会不少,本系列将通过四篇随笔与大家分享. 一.C ...
- http://codeforces.com/contest/610/problem/D
D. Vika and Segments time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- NDK各个版本链接
ndk_r15c (July 2017) Windows 32-bit : https://dl.google.com/android/repository/android-ndk-r15c-wind ...
- java数据库编程之DAO模式
第八章:DAO模式 8.1:JDBC封装 为了提高代码的维护性和扩展性,我们使用JDBC进行封装数据, 先定义统一的API,将操作数据的代码抽象到接口中,业务逻辑代码只需要调用这些接口的实现类的对象, ...
- jQuery中的常用内容总结(三)
jQuery中的常用内容总结(三) 转载请注明地址:http://www.cnblogs.com/funnyzpc/p/7571998.html 内容提要 选择器(第一节) 选择器的扩展方法(第一节) ...
- 对Java Web项目中路径的理解
第一个:文件分隔符 坑比Window.window分隔符 用\;unix采用/.于是用File.separator来跨平台 请注意:这是文件路径.在File f = new File(“c:\\hah ...
- 解决-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HO问题
原因:因为你的编译工具(eclipse/Myeclipse...)没有添加jdk.添加M2_HOME的环境变量. 解决: ①:window->Preferences->java->I ...
- this到底指向哪里
this指向调用它的对象 首先要明确,this指向调用方,谁调用,this指向谁. 直接调用 举个栗子: var test = 'window' ; function testThis () { va ...
- C# Async/await 异步多线程编程
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.N ...