Submission #655455

# Submission time Handle Problem Language Result Execution time Memory
655455 2022-11-04T13:09:25 Z bLIC Mobile (BOI12_mobile) C++17
40 / 100
1000 ms 81200 KB
#include <bits/stdc++.h>
using namespace std;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)(x).size()
#define ft first
#define sd second
#define pb push_back
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef vector<vi> vvi;

#define dbg if(1)

template <class _T>
string printbit(_T x) {string s="";while(x){s=((x%2)?'1':'0')+s;x/=2;} return s;}
template <class _T>
string printbit(_T x, int len) {string s="";while(len--){s=((x%2)?'1':'0')+s;x/=2;} return s;}

const int MOD = 1e9+7;
const int INF = 1e9;
const int maxN = 1e6+5;


ll n;
long double l;
vector<pair<long double, long double>> cor(maxN);


bool check(long double mid){
     vector<pair<long double, long double>> coord;
     for (int i =0;i<n;i++){
          auto p = cor[i];
          auto power = mid;
          if (p.second-power>0) continue;
          else {
               long double len = sqrt(power*power - p.sd*p.sd);
               coord.pb(make_pair(p.ft-len, p.ft+len));
          }
     }
     sort(all(coord));
     if (coord.empty() || coord[0].ft>1e-5) return false;

     long double curr = 0;
     for (auto x:coord){
          if (x.ft-curr>-1e-4) return false;
          curr = max(curr, x.sd);
          if (curr-l>-1e-4) return true;
     }
     return curr-l>-1e-4;
}

void solve(){
     cin>>n>>l;
     for (int i = 0;i<n;i++) {
          cin>>cor[i].ft>>cor[i].sd;
          cor[i].sd = abs(cor[i].sd);
     }
     long double l = 0, r = 1e14;
     while(r-l>1e-5){
          long double mid = (l+r)/2;
          if (check(mid)) r = mid;
          else l = mid;
     }
     cout<<fixed<<setprecision(6)<<r;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
//     cin>>t;

    while(t--){

        solve();
        cout<<endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 25 ms 31632 KB Output is correct
2 Correct 25 ms 31588 KB Output is correct
3 Correct 27 ms 31676 KB Output is correct
4 Correct 26 ms 31548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 31576 KB Output is correct
2 Correct 27 ms 31560 KB Output is correct
3 Correct 30 ms 31640 KB Output is correct
4 Correct 27 ms 31540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 31860 KB Output is correct
2 Correct 38 ms 31864 KB Output is correct
3 Correct 35 ms 31728 KB Output is correct
4 Correct 40 ms 31892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 32052 KB Output is correct
2 Correct 62 ms 32116 KB Output is correct
3 Correct 55 ms 32212 KB Output is correct
4 Correct 41 ms 32120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 32044 KB Output is correct
2 Correct 54 ms 32116 KB Output is correct
3 Correct 58 ms 32092 KB Output is correct
4 Correct 42 ms 32120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 32044 KB Output is correct
2 Correct 56 ms 32240 KB Output is correct
3 Correct 71 ms 32180 KB Output is correct
4 Correct 42 ms 32052 KB Output is correct
5 Correct 47 ms 32232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 430 ms 38156 KB Output is correct
2 Correct 680 ms 38216 KB Output is correct
3 Correct 423 ms 35400 KB Output is correct
4 Correct 325 ms 38152 KB Output is correct
5 Correct 280 ms 35748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 409 ms 38264 KB Output is correct
2 Correct 342 ms 38852 KB Output is correct
3 Correct 391 ms 39344 KB Output is correct
4 Correct 335 ms 39764 KB Output is correct
5 Correct 350 ms 39940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 597 ms 38688 KB Output is correct
2 Correct 768 ms 38360 KB Output is correct
3 Correct 948 ms 38448 KB Output is correct
4 Correct 358 ms 38892 KB Output is correct
5 Correct 454 ms 39492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 760 ms 38928 KB Output is correct
2 Correct 933 ms 38912 KB Output is correct
3 Execution timed out 1074 ms 38928 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 728 ms 39048 KB Output is correct
2 Correct 917 ms 38976 KB Output is correct
3 Execution timed out 1090 ms 39024 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 63764 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 63768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 80884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 80928 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 81096 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 81200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 80936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1047 ms 80888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 81148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 80976 KB Time limit exceeded
2 Halted 0 ms 0 KB -