9B - Running Student

来源:互联网 发布:东京和淘宝和天猫 编辑:程序博客网 时间:2024/05/02 22:51

B. Running Student
time limit per test
1 second
memory limit per test
64 megabytes
input
standard input
output
standard output

And again a misfortune fell on Poor Student. He is being late for an exam.

Having rushed to a bus stop that is in point (0, 0), he got on a minibus and they drove along a straight line, parallel to axis OX, in the direction of increasing x.

Poor Student knows the following:

  • during one run the minibus makes n stops, the i-th stop is in point (xi, 0)
  • coordinates of all the stops are different
  • the minibus drives at a constant speed, equal to vb
  • it can be assumed the passengers get on and off the minibus at a bus stop momentarily
  • Student can get off the minibus only at a bus stop
  • Student will have to get off the minibus at a terminal stop, if he does not get off earlier
  • the University, where the exam will be held, is in point (xu, yu)
  • Student can run from a bus stop to the University at a constant speed vs as long as needed
  • a distance between two points can be calculated according to the following formula: 
  • Student is already on the minibus, so, he cannot get off at the first bus stop

Poor Student wants to get to the University as soon as possible. Help him to choose the bus stop, where he should get off. If such bus stops are multiple, choose the bus stop closest to the University.

Input

The first line contains three integer numbers: 2 ≤ n ≤ 1001 ≤ vb, vs ≤ 1000. The second line contains n non-negative integers in ascending order: coordinates xi of the bus stop with index i. It is guaranteed that x1 equals to zero, and xn ≤ 105. The third line contains the coordinates of the University, integers xu and yu, not exceeding 105 in absolute value.

Output

In the only line output the answer to the problem — index of the optimum bus stop.

Examples
input
4 5 20 2 4 64 1
output
3
input
2 1 10 100000100000 100000
output
2
Note

As you know, students are a special sort of people, and minibuses usually do not hurry. That's why you should not be surprised, if Student's speed is higher than the speed of the minibus.


题目比较简单,不过细节倒不少


题意说,在x轴上有一列公交车站,有个人在第1个站上车了,问他在哪个站下车能用最短的时间到学校,输出车站的编号。


刚开始没看懂题意,直接找距离最近的点,错了

后来发现还是暴力枚举一下比较保险,但是还是错了

看了错误数据才发现,自己忘了车站在x轴上的情况了,加上一个条件判断,过了....



#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>using namespace std;int n,a,b,x[105],ex,ey;double sum(int st)//计算需要的时间{return st*1.0/a+sqrt((ex*1.0-st)*(ex*1.0-st)+ey*1.0*ey)*1.0/b;}int slove(){int ans=2;double time=sum(x[2]);//按题意要求,直接从第二个车站开始算for(int i=3;i<=n;++i){double tp=sum(x[i]);if(tp<time||tp==time&&abs(ex-x[i])<abs(ex-x[ans]))//两级判断{time=tp;ans=i;}}return ans;}int main(){scanf("%d%d%d",&n,&a,&b);for(int i=1;i<=n;++i){scanf("%d",&x[i]);}scanf("%d%d",&ex,&ey);int ans=slove();printf("%d\n",ans);return 0;}



0 0