답안 #1056929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1056929 2024-08-13T12:31:23 Z TimAni Mobile (BOI12_mobile) C++17
50 / 100
1000 ms 40356 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 r = 0;
        while(i < segs.size() && 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:42:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<double, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         while(i < segs.size() && r >= segs[i][0]) {
      |               ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 600 KB Output is correct
2 Correct 7 ms 588 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 5 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 700 KB Output is correct
2 Correct 9 ms 716 KB Output is correct
3 Correct 13 ms 716 KB Output is correct
4 Correct 5 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 720 KB Output is correct
2 Correct 19 ms 788 KB Output is correct
3 Correct 17 ms 748 KB Output is correct
4 Correct 5 ms 784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 700 KB Output is correct
2 Correct 9 ms 712 KB Output is correct
3 Correct 12 ms 740 KB Output is correct
4 Correct 5 ms 716 KB Output is correct
5 Correct 6 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 125 ms 4296 KB Output is correct
2 Correct 249 ms 4836 KB Output is correct
3 Correct 178 ms 3252 KB Output is correct
4 Correct 86 ms 4812 KB Output is correct
5 Correct 80 ms 3104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 121 ms 4372 KB Output is correct
2 Correct 100 ms 4708 KB Output is correct
3 Correct 107 ms 4884 KB Output is correct
4 Correct 99 ms 4852 KB Output is correct
5 Correct 78 ms 6104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 213 ms 4664 KB Output is correct
2 Correct 269 ms 4716 KB Output is correct
3 Correct 277 ms 5244 KB Output is correct
4 Correct 61 ms 6124 KB Output is correct
5 Correct 157 ms 5364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 260 ms 4892 KB Output is correct
2 Correct 350 ms 4892 KB Output is correct
3 Correct 355 ms 5656 KB Output is correct
4 Correct 63 ms 6172 KB Output is correct
5 Correct 127 ms 4884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 215 ms 4900 KB Output is correct
2 Correct 321 ms 4868 KB Output is correct
3 Correct 405 ms 4916 KB Output is correct
4 Correct 65 ms 4792 KB Output is correct
5 Correct 125 ms 4896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1036 ms 20532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1025 ms 20452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1012 ms 33872 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1020 ms 31708 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1059 ms 33596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1055 ms 33688 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1040 ms 36992 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 36128 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1024 ms 40356 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1050 ms 40356 KB Time limit exceeded
2 Halted 0 ms 0 KB -