Submission #1093048

# Submission time Handle Problem Language Result Execution time Memory
1093048 2024-09-25T18:41:51 Z TommasoUlian Mobile (BOI12_mobile) C++17
0 / 100
940 ms 48192 KB
#include <bits/stdc++.h>
#define PB push_back
#define MP makepair
#ifndef ONLINE_JUDGE
#define DEBUG(x) cout << #x << " = " << (x) << endl
#else
#define DEBUG(x)
#endif
#define FOR(n) for(int i = 0; i < (n); i++)
#define SORTA(v) sort((v).begin(), (v).end())
#define SORTD(v) sort((v).rbegin(), (v).rend())
#define PRINT(v) for(auto x: (v))cout << x << " "; cout << endl;
#define TWO(n) (1 << (n))
#define INPUT(v) for(auto &x : (v))cin >> x;
#pragma GCC optimize("Ofast,no-stack-protector",3)
 
typedef long long ll;
 
using namespace std;
 
vector<pair<double,double>> torri;
ll n,L;
 
bool good(double r){
    queue<pair<double,double>> s;
    
    for(auto a:torri){
        double x = a.first, y = a.second;
        if (abs(y) <= r+10e-6)s.push({x-sqrt((r+y)*(r-y)),x+sqrt((r+y)*(r-y))});
       
    }
    double curr = 0;
    while(!s.empty()){
        if(curr >= L)return true;
        auto seg = s.front();
        s.pop();
        if(seg.first <= curr){
            curr = max(seg.second,curr);
        }
        else return false;
    }
    if(curr < L)return false;
    return true;
}
 
void solve(){
    cin >> n >> L;
    torri = vector<pair<double,double>>(n);
    for(int i = 0; i < n; i++){
        cin >> torri[i].first >> torri[i].second;
 
    }
    double l = 1, r = 20e14;
    double ans = r;
    while(r-l >= 0.00001){
        double c = (r+l)/2;
        //cout << c << endl;
        if(good(c)){
            ans = min(ans,c);
            r = c;
        }
        else{
            l = c;
        }
 
    }
    
    cout << ans << endl;
    
}
 
int main(){
    cout << setprecision(18);
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Incorrect 3 ms 604 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 3788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 3732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 4080 KB Output is correct
2 Incorrect 66 ms 4252 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 5316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 93 ms 5396 KB Output is correct
2 Incorrect 83 ms 5232 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 418 ms 20672 KB Output is correct
2 Correct 444 ms 24304 KB Output is correct
3 Correct 435 ms 23804 KB Output is correct
4 Incorrect 292 ms 26052 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 442 ms 24340 KB Output is correct
2 Incorrect 449 ms 23112 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 520 ms 24148 KB Output is correct
2 Incorrect 562 ms 29032 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 522 ms 27440 KB Output is correct
2 Incorrect 517 ms 27680 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 587 ms 28160 KB Output is correct
2 Incorrect 624 ms 33820 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 661 ms 31972 KB Output is correct
2 Incorrect 597 ms 32224 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 717 ms 31820 KB Output is correct
2 Incorrect 719 ms 38560 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 747 ms 36448 KB Output is correct
2 Incorrect 694 ms 37004 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 922 ms 39684 KB Output is correct
2 Incorrect 901 ms 48192 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 940 ms 45324 KB Output is correct
2 Incorrect 845 ms 45760 KB Output isn't correct
3 Halted 0 ms 0 KB -