Submission #1056958

# Submission time Handle Problem Language Result Execution time Memory
1056958 2024-08-13T12:42:11 Z TimAni Mobile (BOI12_mobile) C++17
100 / 100
362 ms 13644 KB
// time-limit: 3000
 
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
const double eps = 1e-6;
 
struct point {
    int x{}, y{};
};
 
void solve() {
    int n, L;
    cin >> n >> L;
    vector<point> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    auto intersection = [&](const point& A, double R) -> array<double, 2> {
        if(abs(A.y) > R) {
            return {L + 2, -2};
        }
        double D = 1.0 * R * R - 1.0 * A.y * A.y; // divided by 4
        double x1 = A.x - sqrt(D);
        double x2 = A.x + sqrt(D);
        if(x2 < x1) swap(x1, x2);
        if(x1 < 0) x1 = -1; 
        if(x2 > L) x2 = L + 1;
        if(x2 < 0 || x1 > L)
            return {L + 2, -2};
        return {x1, x2};
    };
 
    auto good = [&](double R) {
        double mx = 0;
        for(int i = 0; i < n; i++) {
            auto [l, r] = intersection(p[i], R);
            if(l <= mx && r > mx) mx = r;
        }
        return mx >= L;
    };
 
    double l = 0, r = 4e9;
    while(r - l > eps) {
        double R = (r + l) / 2;
        if(good(R)) {
            r = R;
        }
        else {
            l = R;
        }
        
    }
    cout << fixed << setprecision(-log10(eps)) << r << endl;
}
 
int main() {
    cin.tie(0)->sync_with_stdio(0);
    double T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}

Compilation message

mobile.cpp: In lambda function:
mobile.cpp:23:23: warning: narrowing conversion of '(L + 2)' from 'int' to 'double' [-Wnarrowing]
   23 |             return {L + 2, -2};
      |                     ~~^~~
mobile.cpp:32:23: warning: narrowing conversion of '(L + 2)' from 'int' to 'double' [-Wnarrowing]
   32 |             return {L + 2, -2};
      |                     ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# 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 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 856 KB Output is correct
2 Correct 22 ms 1076 KB Output is correct
3 Correct 14 ms 892 KB Output is correct
4 Correct 20 ms 860 KB Output is correct
5 Correct 11 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1076 KB Output is correct
2 Correct 16 ms 856 KB Output is correct
3 Correct 18 ms 1108 KB Output is correct
4 Correct 17 ms 1112 KB Output is correct
5 Correct 19 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1112 KB Output is correct
2 Correct 25 ms 1112 KB Output is correct
3 Correct 22 ms 1132 KB Output is correct
4 Correct 21 ms 1116 KB Output is correct
5 Correct 19 ms 1168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1116 KB Output is correct
2 Correct 29 ms 1116 KB Output is correct
3 Correct 25 ms 1256 KB Output is correct
4 Correct 21 ms 1116 KB Output is correct
5 Correct 24 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 1116 KB Output is correct
2 Correct 30 ms 1116 KB Output is correct
3 Correct 25 ms 1116 KB Output is correct
4 Correct 22 ms 1112 KB Output is correct
5 Correct 23 ms 1252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 135 ms 4364 KB Output is correct
2 Correct 145 ms 4368 KB Output is correct
3 Correct 145 ms 6236 KB Output is correct
4 Correct 109 ms 7180 KB Output is correct
5 Correct 106 ms 6496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 147 ms 4184 KB Output is correct
2 Correct 207 ms 6236 KB Output is correct
3 Correct 126 ms 6100 KB Output is correct
4 Correct 102 ms 6744 KB Output is correct
5 Correct 118 ms 6236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 175 ms 4952 KB Output is correct
2 Correct 173 ms 5136 KB Output is correct
3 Correct 178 ms 7504 KB Output is correct
4 Correct 127 ms 8472 KB Output is correct
5 Correct 127 ms 7256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 181 ms 4956 KB Output is correct
2 Correct 239 ms 7300 KB Output is correct
3 Correct 151 ms 6992 KB Output is correct
4 Correct 122 ms 8532 KB Output is correct
5 Correct 125 ms 7508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 190 ms 5724 KB Output is correct
2 Correct 208 ms 8876 KB Output is correct
3 Correct 201 ms 8748 KB Output is correct
4 Correct 149 ms 9304 KB Output is correct
5 Correct 148 ms 8472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 205 ms 5724 KB Output is correct
2 Correct 263 ms 8272 KB Output is correct
3 Correct 174 ms 8232 KB Output is correct
4 Correct 142 ms 9296 KB Output is correct
5 Correct 147 ms 8744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 215 ms 6704 KB Output is correct
2 Correct 255 ms 10040 KB Output is correct
3 Correct 260 ms 9904 KB Output is correct
4 Correct 167 ms 10832 KB Output is correct
5 Correct 169 ms 9560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 240 ms 6492 KB Output is correct
2 Correct 292 ms 9560 KB Output is correct
3 Correct 201 ms 9308 KB Output is correct
4 Correct 167 ms 10580 KB Output is correct
5 Correct 166 ms 9808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 281 ms 8284 KB Output is correct
2 Correct 301 ms 12372 KB Output is correct
3 Correct 286 ms 11988 KB Output is correct
4 Correct 224 ms 13644 KB Output is correct
5 Correct 210 ms 11852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 300 ms 8280 KB Output is correct
2 Correct 362 ms 11844 KB Output is correct
3 Correct 251 ms 11596 KB Output is correct
4 Correct 204 ms 13400 KB Output is correct
5 Correct 206 ms 12384 KB Output is correct