Submission #553421

# Submission time Handle Problem Language Result Execution time Memory
553421 2022-04-25T19:34:01 Z Hona_Nguyen Mobile (BOI12_mobile) C++14
50 / 100
1000 ms 48352 KB
#include<bits/stdc++.h>
#define prob "mobile"
#define x first
#define y second
using namespace std;
const int maxn = 1e6;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
int n,L;
pair<double,double> p[maxn+5];
int main(){
//    freopen(prob".in","r",stdin);
//    freopen(prob".out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n >> L;
    for(int i=1;i<=n;i++) cin >> p[i].x >> p[i].y;
    auto check = [&](double val) -> int{
        vector<pair<double,double>> G;
        for(int i=1;i<=n;i++){
//            if(val < p[i].y) return 0;
            double tmp = sqrt(val*val-p[i].y*p[i].y);
            double xL = p[i].x - tmp;
            double xR = p[i].x + tmp;
            G.push_back(make_pair(xL,xR));
        }
//        sort(G.begin(),G.end(), [](const pair<double,double> A, const pair<double,double> B){
//             if(A.first == B.first) return A.second < B.second;
//             return A.first < B.first;
//             });
        double curx = 0;
        for(int i=0;i<n;i++){
            if(G[i].x <= curx){
               curx = max(curx, G[i].y);
            }
        }
        if(curx >= (double)(L)) return 1;
        return 0;
    };
    double low = 1, high = (double)(2e9), res = 0;
    for(int i=1;i<=300;i++){
        if(high - low < eps) break;
        double mid = (low + high) / (double)(2);
        if(check(mid)){
            res = mid;
            high = mid;
        }
        else{
            low = mid;
        }
    }
    cout << fixed << setprecision(4);
    cout << res;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 4 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 612 KB Output is correct
2 Correct 33 ms 1744 KB Output is correct
3 Correct 7 ms 664 KB Output is correct
4 Correct 9 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 612 KB Output is correct
2 Correct 26 ms 676 KB Output is correct
3 Correct 7 ms 664 KB Output is correct
4 Correct 8 ms 692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 628 KB Output is correct
2 Correct 27 ms 612 KB Output is correct
3 Correct 7 ms 612 KB Output is correct
4 Correct 8 ms 692 KB Output is correct
5 Correct 8 ms 660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 150 ms 4816 KB Output is correct
2 Correct 564 ms 6008 KB Output is correct
3 Correct 87 ms 3716 KB Output is correct
4 Correct 153 ms 6016 KB Output is correct
5 Correct 82 ms 3380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 140 ms 5056 KB Output is correct
2 Correct 143 ms 5560 KB Output is correct
3 Correct 151 ms 6084 KB Output is correct
4 Correct 167 ms 6164 KB Output is correct
5 Correct 178 ms 6920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 146 ms 5224 KB Output is correct
2 Correct 594 ms 5328 KB Output is correct
3 Correct 145 ms 5300 KB Output is correct
4 Correct 187 ms 7496 KB Output is correct
5 Correct 155 ms 6304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 687 ms 5728 KB Output is correct
2 Correct 678 ms 5796 KB Output is correct
3 Correct 171 ms 5704 KB Output is correct
4 Correct 193 ms 7608 KB Output is correct
5 Correct 176 ms 6844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 170 ms 5616 KB Output is correct
2 Correct 653 ms 5656 KB Output is correct
3 Correct 168 ms 5756 KB Output is correct
4 Correct 196 ms 7536 KB Output is correct
5 Correct 177 ms 7012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 24528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 24340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 35736 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 35828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 38800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 38708 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 41892 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 41940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 48352 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 48192 KB Time limit exceeded
2 Halted 0 ms 0 KB -