Submission #655574

# Submission time Handle Problem Language Result Execution time Memory
655574 2022-11-04T18:34:35 Z bLIC Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 83084 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 31556 KB Output is correct
2 Correct 25 ms 31572 KB Output is correct
3 Incorrect 26 ms 31608 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 31544 KB Output is correct
2 Correct 26 ms 31592 KB Output is correct
3 Correct 24 ms 31564 KB Output is correct
4 Incorrect 27 ms 31568 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 31872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 32116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 35 ms 32100 KB Output is correct
2 Correct 38 ms 32124 KB Output is correct
3 Incorrect 37 ms 32324 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 32120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 223 ms 38980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 193 ms 39104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 332 ms 39276 KB Output is correct
2 Incorrect 281 ms 39736 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 334 ms 40472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 362 ms 40456 KB Output is correct
2 Incorrect 334 ms 40384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 65824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 65724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 83064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 82516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1038 ms 83016 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 82488 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 83084 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 82528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1010 ms 82928 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1016 ms 82444 KB Time limit exceeded
2 Halted 0 ms 0 KB -