Submission #1056927

# Submission time Handle Problem Language Result Execution time Memory
1056927 2024-08-13T12:30:37 Z TimAni Mobile (BOI12_mobile) C++17
8 / 100
1000 ms 40352 KB
// time-limit: 3000
 
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
const double eps = 1E-4;
 
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 {1e18, -1e18};
        }
        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);
        return {x1, x2};
    };
 
    auto good = [&](double R) {
        vector<array<double, 2>> segs;
        for(int i = 0; i < n; i++) {
            if(abs(p[i].y) > R) continue;
            segs.push_back(intersection(p[i], R));
        }
        if(segs.empty()) return false;
        sort(segs.begin(), segs.end());
        int i = 0;
        double l = 0, r = 0;
        while(i < n && r >= segs[i][0]) {
            r = max(r, segs[i][1]); i++;
        }
        return r >= 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:41:16: warning: unused variable 'l' [-Wunused-variable]
   41 |         double l = 0, r = 0;
      |                ^
# 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 348 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 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Incorrect 4 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 896 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 716 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 712 KB Output is correct
2 Correct 10 ms 700 KB Output is correct
3 Runtime error 6 ms 820 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 97 ms 5144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 117 ms 5172 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 191 ms 4644 KB Output is correct
2 Correct 256 ms 4464 KB Output is correct
3 Runtime error 105 ms 5916 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 260 ms 4916 KB Output is correct
2 Correct 320 ms 4864 KB Output is correct
3 Correct 355 ms 4868 KB Output is correct
4 Runtime error 54 ms 5940 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 216 ms 4952 KB Output is correct
2 Correct 318 ms 4872 KB Output is correct
3 Correct 355 ms 5148 KB Output is correct
4 Runtime error 58 ms 5176 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 20552 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1032 ms 20960 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 31280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 32064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 35248 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1004 ms 34372 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1041 ms 36004 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1050 ms 35696 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 40352 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1030 ms 40336 KB Time limit exceeded
2 Halted 0 ms 0 KB -