Submission #1093041

# Submission time Handle Problem Language Result Execution time Memory
1093041 2024-09-25T18:20:49 Z TommasoUlian Mobile (BOI12_mobile) C++17
0 / 100
990 ms 49032 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 - 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.front();
        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 = (l + (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 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 600 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 Incorrect 3 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 60 ms 3904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 3840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 85 ms 4076 KB Output is correct
2 Incorrect 80 ms 4388 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 5192 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 5172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 438 ms 20932 KB Output is correct
2 Correct 410 ms 24304 KB Output is correct
3 Correct 485 ms 24004 KB Output is correct
4 Incorrect 476 ms 26088 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 461 ms 24776 KB Output is correct
2 Incorrect 450 ms 23156 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 559 ms 24952 KB Output is correct
2 Incorrect 624 ms 29076 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 554 ms 29840 KB Output is correct
2 Incorrect 572 ms 27880 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 592 ms 29036 KB Output is correct
2 Incorrect 680 ms 33832 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 667 ms 34504 KB Output is correct
2 Incorrect 677 ms 32328 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 736 ms 33148 KB Output is correct
2 Incorrect 744 ms 38568 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 780 ms 39408 KB Output is correct
2 Incorrect 696 ms 36880 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 990 ms 41272 KB Output is correct
2 Incorrect 942 ms 48132 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 956 ms 49032 KB Output is correct
2 Incorrect 918 ms 45700 KB Output isn't correct
3 Halted 0 ms 0 KB -