Advertisement
MinhNGUYEN2k4

Untitled

Nov 14th, 2021
952
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. const int N = 1010;
  2. const int oo=0x3f;
  3. const int mod=1e9+7;
  4. const int base=311;
  5. const double EP=1e-9;
  6. int n,a[N],vb,vs,u,v;
  7. double kc(int x, int u1, int v1){
  8.     int dx=abs(x-u1);
  9.     int dy=abs(v1);
  10.     return sqrt(dx*dx+dy*dy);
  11. }
  12. double f(int x){
  13.     double t1=x/vb;
  14.     double t2=kc(x,u,v)/vs;
  15.     return t1+t2;
  16. }
  17. void init(){
  18.   FAST;
  19.   if (fopen(TASK".INP","r")){
  20.     READFILE;
  21.     WRITEFILE;
  22.   }
  23.   cin >> n >> vb >> vs;
  24.   For(i,1,n){
  25.     cin >> a[i];
  26.   }
  27.   cin >> u >> v;
  28. }
  29. signed main()
  30. {
  31.   init();
  32.   pair<double,double> ans;
  33.   ans.fi=ans.se=10000000;
  34.   int id=0;
  35.   For(i,2,n){
  36.     double res=f(a[i]);
  37.     if (ans.fi>res) {
  38.         id=i;
  39.         ans.fi=res;
  40.         ans.se=kc(a[i],u,v);
  41.     } else if (abs(ans.fi-res)<EP) {
  42.         if (ans.se<kc(a[i],u,v)) {
  43.             ans.se=kc(a[i],u,v);
  44.             id=i;
  45.         }
  46.     }
  47.   }
  48.   cout << id;
  49.   return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement