• codeforces


     1 #include <iostream>
     2 #include <algorithm>
     3 #include <cstring>
     4 #include <cstdio>
     5 #include <bitset>
     6 #include <vector>
     7 #include <queue>
     8 #include <stack>
     9 #include <cmath>
    10 #include <list>
    11 #include <set>
    12 #include <map>
    13 #define rep(i,a,b) for(int i = a;i <= b;++ i)
    14 #define per(i,a,b) for(int i = a;i >= b;-- i)
    15 #define mem(a,b) memset((a),(b),sizeof((a)))
    16 #define FIN freopen("in.txt","r",stdin)
    17 #define FOUT freopen("out.txt","w",stdout)
    18 #define IO ios_base::sync_with_stdio(0),cin.tie(0)
    19 #define mid ((l+r)>>1)
    20 #define ls (id<<1)
    21 #define rs ((id<<1)|1)
    22 #define INF 0x3f3f3f3f
    23 using namespace std;
    24 typedef long long LL;
    25 typedef pair<int, int> PIR;
    26 const int N = 6e4+5;
    27 
    28 int n;
    29 double x[N], v[N];
    30 bool judge(double md){
    31     double l = 0, r = 1e9*1.0;
    32     rep (i, 1, n) {
    33         double ll = x[i]-v[i]*md, rr = x[i]+v[i]*md;
    34         if(ll < l && ll > r && rr < l && rr > r)    return false;
    35         l = max(ll, l);
    36         r = min(rr, r);
    37         if(l > r)    return false;
    38     }
    39     return true;
    40 }
    41 int main()
    42 {
    43     //FIN;
    44     while (scanf("%d", &n) != EOF) {
    45         rep (i, 1, n)    scanf("%lf", &x[i]);
    46         rep (i, 1, n)    scanf("%lf", &v[i]);
    47         double low = 0, high = 1e9*1.0, ans = 0;
    48         rep (i, 1, 300) {
    49             double md = (low+high)/2;
    50             if(judge(md))    { high = md-1; ans = md; }
    51             else low = md+1;
    52         }
    53         printf("%.6lf
    ", ans);
    54     }
    55     return 0;
    56 }
    View Code
  • 相关阅读:
    P1486 [NOI2004]郁闷的出纳员
    P1966 火柴排队
    P2627 修剪草坪
    P1621 集合
    P1025 数的划分
    中国剩余定理
    P2043 质因子分解
    P1075 质因数分解
    C#之引用类型参数
    C#之方法的定义及调用学习案例
  • 原文地址:https://www.cnblogs.com/NWUACM/p/6543308.html
Copyright © 2020-2023  润新知