Submission #1093045

# Submission time Handle Problem Language Result Execution time Memory
1093045 2024-09-25T18:24:07 Z TommasoUlian Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 56936 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){
    priority_queue<pair<double,double>, vector<pair<double,double>>, greater<pair<double,double>>> s;
    
    for(auto a:torri){
        double x = a.first, y = a.second;
        if (abs(y) <= r - 1e-6)s.push({max(0.0,x-sqrt(r*r-y*y)),min((double)L,x+sqrt(r*r-y*y))});
    }
    double curr = 0;
    while(!s.empty()){
        if(curr >= L)return true;
        auto seg = s.top();
        s.pop();
        if(seg.first <= curr){
            curr = seg.second;
        }
        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.000001){
        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 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 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 9 ms 796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 179 ms 5748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 185 ms 5800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 444 ms 6048 KB Output is correct
2 Correct 123 ms 6556 KB Output is correct
3 Correct 113 ms 6192 KB Output is correct
4 Incorrect 243 ms 7684 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 139 ms 7332 KB Output is correct
2 Correct 154 ms 7176 KB Output is correct
3 Correct 145 ms 6784 KB Output is correct
4 Incorrect 307 ms 7836 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 221 ms 7240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1027 ms 27928 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 741 ms 31044 KB Output is correct
2 Execution timed out 1055 ms 29716 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1039 ms 40268 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1044 ms 43972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1046 ms 43868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1002 ms 48184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1037 ms 45884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 49144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 52832 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1014 ms 56936 KB Time limit exceeded
2 Halted 0 ms 0 KB -