Submission #1083687

# Submission time Handle Problem Language Result Execution time Memory
1083687 2024-09-03T20:23:16 Z vjudge1 Mobile (BOI12_mobile) C++17
95 / 100
1000 ms 35420 KB
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

// Function to check if all points on the highway [0, L] can be covered with distance R
bool canCoverAllPoints(const vector<pair<double, double>>& stations, double R, double L) {
    double currentCoverage = 0.0;
    
    for (const auto& station : stations) {
        double xi = station.first;
        double yi = station.second;
        
        if (yi > R) continue; // This base station cannot help at this R
        
        double reach = sqrt(R * R - yi * yi);
        double startCoverage = max(0.0, xi - reach);
        double endCoverage = xi + reach;
        
        // Extend coverage if this base station helps
        if (startCoverage <= currentCoverage) {
            currentCoverage = max(currentCoverage, endCoverage);
        }
        
        if (currentCoverage >= L) return true;
    }
    
    return currentCoverage >= L;
}

int main() {
    int N;
    double L;
    cin >> N >> L;

    vector<pair<double, double>> stations(N);
    for (int i = 0; i < N; ++i) {
        double xi, yi;
        cin >> xi >> yi;
        stations[i] = {xi, yi};
    }

    // Binary search for the smallest possible R
    double low = 0.0;
    double high = 1e9;
    double epsilon = 1e-4; // Precision to ensure accuracy within 1e-3

    while (high - low > epsilon) {
        double mid = (low + high) / 2.0;
        if (canCoverAllPoints(stations, mid, L)) {
            high = mid; // Try smaller radius
        } else {
            low = mid; // Increase radius
        }
    }

    cout << fixed << setprecision(6) << high << endl;
    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 Correct 1 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 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 2 ms 344 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 2 ms 556 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 4 ms 580 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 5 ms 588 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 2128 KB Output is correct
2 Correct 50 ms 2512 KB Output is correct
3 Correct 30 ms 1884 KB Output is correct
4 Correct 63 ms 2748 KB Output is correct
5 Correct 25 ms 1596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 1936 KB Output is correct
2 Correct 50 ms 2136 KB Output is correct
3 Correct 63 ms 2644 KB Output is correct
4 Correct 68 ms 2652 KB Output is correct
5 Correct 76 ms 3048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 2140 KB Output is correct
2 Correct 50 ms 2388 KB Output is correct
3 Correct 46 ms 2640 KB Output is correct
4 Correct 98 ms 3796 KB Output is correct
5 Correct 56 ms 2744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 2848 KB Output is correct
2 Correct 65 ms 3388 KB Output is correct
3 Correct 52 ms 2896 KB Output is correct
4 Correct 100 ms 3768 KB Output is correct
5 Correct 78 ms 3160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 2900 KB Output is correct
2 Correct 62 ms 3152 KB Output is correct
3 Correct 51 ms 3012 KB Output is correct
4 Correct 108 ms 3912 KB Output is correct
5 Correct 72 ms 3260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 278 ms 10324 KB Output is correct
2 Correct 339 ms 12144 KB Output is correct
3 Correct 308 ms 15440 KB Output is correct
4 Correct 489 ms 17748 KB Output is correct
5 Correct 413 ms 14932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 359 ms 12384 KB Output is correct
2 Correct 348 ms 14672 KB Output is correct
3 Correct 262 ms 13904 KB Output is correct
4 Correct 469 ms 17492 KB Output is correct
5 Correct 404 ms 15440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 337 ms 12628 KB Output is correct
2 Correct 394 ms 14480 KB Output is correct
3 Correct 373 ms 18516 KB Output is correct
4 Correct 603 ms 21588 KB Output is correct
5 Correct 463 ms 17740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 435 ms 14876 KB Output is correct
2 Correct 399 ms 17740 KB Output is correct
3 Correct 345 ms 16716 KB Output is correct
4 Correct 585 ms 21332 KB Output is correct
5 Correct 488 ms 18516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 393 ms 14812 KB Output is correct
2 Correct 484 ms 16844 KB Output is correct
3 Correct 449 ms 21496 KB Output is correct
4 Correct 684 ms 24916 KB Output is correct
5 Correct 507 ms 20304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 489 ms 17064 KB Output is correct
2 Correct 466 ms 20452 KB Output is correct
3 Correct 389 ms 19700 KB Output is correct
4 Correct 684 ms 24656 KB Output is correct
5 Correct 576 ms 21332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 449 ms 16724 KB Output is correct
2 Correct 551 ms 19272 KB Output is correct
3 Correct 502 ms 24532 KB Output is correct
4 Correct 783 ms 28548 KB Output is correct
5 Correct 637 ms 23892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 631 ms 19792 KB Output is correct
2 Correct 544 ms 23380 KB Output is correct
3 Correct 439 ms 22356 KB Output is correct
4 Correct 789 ms 28240 KB Output is correct
5 Correct 673 ms 24400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 549 ms 20684 KB Output is correct
2 Correct 666 ms 23892 KB Output is correct
3 Correct 656 ms 30664 KB Output is correct
4 Correct 987 ms 35288 KB Output is correct
5 Correct 769 ms 29676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 744 ms 24408 KB Output is correct
2 Correct 664 ms 29248 KB Output is correct
3 Correct 552 ms 28240 KB Output is correct
4 Execution timed out 1004 ms 35420 KB Time limit exceeded
5 Halted 0 ms 0 KB -