Submission #655581

# Submission time Handle Problem Language Result Execution time Memory
655581 2022-11-04T18:45:53 Z bLIC Mobile (BOI12_mobile) C++17
100 / 100
874 ms 31692 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){
     long double curr = 0;
     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);
               auto x = (make_pair(p.ft-len, p.ft+len));
               if (x.ft>curr) continue;
               curr = max(curr, x.sd);
               if (curr>=l) return true;
          }
     }
     // if (coord.empty() || coord[0].ft>1e-5) return false;

     return curr>=l;
}

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 = 1e10;
     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 24 ms 31572 KB Output is correct
2 Correct 24 ms 31572 KB Output is correct
3 Correct 24 ms 31564 KB Output is correct
4 Correct 24 ms 31620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 31572 KB Output is correct
2 Correct 24 ms 31572 KB Output is correct
3 Correct 24 ms 31544 KB Output is correct
4 Correct 23 ms 31572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 31644 KB Output is correct
2 Correct 26 ms 31564 KB Output is correct
3 Correct 26 ms 31568 KB Output is correct
4 Correct 26 ms 31632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 31596 KB Output is correct
2 Correct 28 ms 31572 KB Output is correct
3 Correct 27 ms 31592 KB Output is correct
4 Correct 27 ms 31572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 31548 KB Output is correct
2 Correct 28 ms 31632 KB Output is correct
3 Correct 27 ms 31624 KB Output is correct
4 Correct 27 ms 31640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 31692 KB Output is correct
2 Correct 28 ms 31644 KB Output is correct
3 Correct 28 ms 31552 KB Output is correct
4 Correct 28 ms 31572 KB Output is correct
5 Correct 27 ms 31572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 31540 KB Output is correct
2 Correct 65 ms 31516 KB Output is correct
3 Correct 56 ms 31516 KB Output is correct
4 Correct 86 ms 31596 KB Output is correct
5 Correct 45 ms 31592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 31572 KB Output is correct
2 Correct 59 ms 31564 KB Output is correct
3 Correct 71 ms 31564 KB Output is correct
4 Correct 71 ms 31572 KB Output is correct
5 Correct 80 ms 31564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 96 ms 31608 KB Output is correct
2 Correct 69 ms 31560 KB Output is correct
3 Correct 65 ms 31540 KB Output is correct
4 Correct 94 ms 31664 KB Output is correct
5 Correct 66 ms 31564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 31564 KB Output is correct
2 Correct 78 ms 31556 KB Output is correct
3 Correct 71 ms 31624 KB Output is correct
4 Correct 93 ms 31544 KB Output is correct
5 Correct 78 ms 31532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 31540 KB Output is correct
2 Correct 79 ms 31572 KB Output is correct
3 Correct 79 ms 31668 KB Output is correct
4 Correct 102 ms 31592 KB Output is correct
5 Correct 82 ms 31572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 394 ms 31536 KB Output is correct
2 Correct 332 ms 31572 KB Output is correct
3 Correct 324 ms 31576 KB Output is correct
4 Correct 368 ms 31520 KB Output is correct
5 Correct 310 ms 31592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 345 ms 31524 KB Output is correct
2 Correct 418 ms 31572 KB Output is correct
3 Correct 295 ms 31592 KB Output is correct
4 Correct 353 ms 31536 KB Output is correct
5 Correct 324 ms 31572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 472 ms 31540 KB Output is correct
2 Correct 396 ms 31564 KB Output is correct
3 Correct 346 ms 31644 KB Output is correct
4 Correct 472 ms 31572 KB Output is correct
5 Correct 346 ms 31572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 411 ms 31520 KB Output is correct
2 Correct 498 ms 31572 KB Output is correct
3 Correct 316 ms 31564 KB Output is correct
4 Correct 432 ms 31644 KB Output is correct
5 Correct 370 ms 31564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 517 ms 31576 KB Output is correct
2 Correct 463 ms 31528 KB Output is correct
3 Correct 416 ms 31600 KB Output is correct
4 Correct 548 ms 31572 KB Output is correct
5 Correct 445 ms 31528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 500 ms 31572 KB Output is correct
2 Correct 602 ms 31572 KB Output is correct
3 Correct 406 ms 31572 KB Output is correct
4 Correct 508 ms 31564 KB Output is correct
5 Correct 531 ms 31572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 675 ms 31572 KB Output is correct
2 Correct 560 ms 31580 KB Output is correct
3 Correct 462 ms 31572 KB Output is correct
4 Correct 597 ms 31640 KB Output is correct
5 Correct 507 ms 31572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 586 ms 31576 KB Output is correct
2 Correct 720 ms 31536 KB Output is correct
3 Correct 515 ms 31576 KB Output is correct
4 Correct 645 ms 31528 KB Output is correct
5 Correct 585 ms 31600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 869 ms 31632 KB Output is correct
2 Correct 676 ms 31564 KB Output is correct
3 Correct 695 ms 31652 KB Output is correct
4 Correct 771 ms 31564 KB Output is correct
5 Correct 677 ms 31564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 707 ms 31544 KB Output is correct
2 Correct 874 ms 31572 KB Output is correct
3 Correct 647 ms 31572 KB Output is correct
4 Correct 789 ms 31564 KB Output is correct
5 Correct 656 ms 31612 KB Output is correct