Submission #1093057

# Submission time Handle Problem Language Result Execution time Memory
1093057 2024-09-25T18:56:42 Z TommasoUlian Mobile (BOI12_mobile) C++17
0 / 100
722 ms 49208 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;
 
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- 10e-6 <= 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 = 2e9;
    double ans = r;
    while(r-l >= 10e-6){
        double c = (r + l) / 2;        //cout << c << endl;
        if(good(c)){
            r = c;
            ans = min(ans,r);
        }
        else{
            l = c;
        }
 
    }
    
    cout << setprecision(log10(ans)+6) << (l + r) / 2 << endl;
    
}
 
int main(){
    cout << setprecision(18);
    ios::sync_with_stdio(false);

    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 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 0 ms 452 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 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 3 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 3664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 3732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 57 ms 3968 KB Output is correct
2 Incorrect 54 ms 4244 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 74 ms 5212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 69 ms 5288 KB Output is correct
2 Incorrect 69 ms 5208 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 343 ms 20832 KB Output is correct
2 Correct 374 ms 24304 KB Output is correct
3 Correct 332 ms 23812 KB Output is correct
4 Incorrect 202 ms 25972 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 365 ms 24680 KB Output is correct
2 Incorrect 380 ms 23112 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 429 ms 25020 KB Output is correct
2 Incorrect 425 ms 29028 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 420 ms 29660 KB Output is correct
2 Incorrect 427 ms 27676 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 486 ms 29056 KB Output is correct
2 Incorrect 471 ms 33840 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 490 ms 34516 KB Output is correct
2 Incorrect 487 ms 32208 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 583 ms 33240 KB Output is correct
2 Incorrect 619 ms 38568 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 593 ms 39364 KB Output is correct
2 Incorrect 545 ms 36700 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 722 ms 41480 KB Output is correct
2 Incorrect 690 ms 48128 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 706 ms 49208 KB Output is correct
2 Incorrect 713 ms 45716 KB Output isn't correct
3 Halted 0 ms 0 KB -