Submission #466087

# Submission time Handle Problem Language Result Execution time Memory
466087 2021-08-17T21:59:46 Z joshualiu555 Mobile (BOI12_mobile) C++14
60 / 100
1000 ms 48320 KB
/*
  _____                                     _        _
 / ____|                                   | |      | |
| |  __ _ __ __ _ ___ ___ _   _ _ __   ___ | |_ __ _| |_ ___
| | |_ | '__/ _` / __/ __| | | | '_ \ / _ \| __/ _` | __/ _ \
| |__| | | | (_| \__ \__ \ |_| | |_) | (_) | || (_| | || (_) |
 \_____|_|  \__,_|___/___/\__, | .__/ \___/ \__\__,_|\__\___/
                           __/ | |
                          |___/|_|
*/

#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <array>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <cstring>
#include <bitset>
#include <string>
#include <sstream>

using namespace std;

using ll = long long;
const int INF = 1e6 + 5;
const int MOD = 1e9 + 7;
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

int N, L;
pair<ll, ll> xy[INF];

bool check (double radius) {
    vector<pair<double, double>> seg;
    for (int i = 0; i < N; i++) {
        double horz = sqrt(radius * radius - xy[i].second * xy[i].second);
        double left = xy[i].first - horz, right = xy[i].first + horz;
        seg.push_back(make_pair(left, right));
    }
    double current = 0;
    for (int i = 0; i < N; i++) {
        if (seg[i].first <= current) current = max(current, seg[i].second);
    }
    return current >= L;
}

int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(0);

//    ifstream cin(".in");
//    ofstream cout(".out");

    cin >> N >> L;
    for (int i = 0; i < N; i++) cin >> xy[i].first >> xy[i].second;

    double l = 0, r = 1.5 * 1e9;
    for (int i = 0; i < 50; i++) {
        double m = (l + r) / 2;
        if (check(m)) {
            r = m;
        } else {
            l = m;
        }
    }

    cout << fixed << setprecision(6) << l << '\n';

    return 0;
}

/*
 *
*/

//
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 620 KB Output is correct
2 Correct 7 ms 620 KB Output is correct
3 Correct 7 ms 604 KB Output is correct
4 Correct 9 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 604 KB Output is correct
2 Correct 6 ms 620 KB Output is correct
3 Correct 6 ms 604 KB Output is correct
4 Correct 7 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 608 KB Output is correct
2 Correct 6 ms 604 KB Output is correct
3 Correct 6 ms 608 KB Output is correct
4 Correct 7 ms 620 KB Output is correct
5 Correct 8 ms 788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 128 ms 4948 KB Output is correct
2 Correct 123 ms 4912 KB Output is correct
3 Correct 79 ms 3084 KB Output is correct
4 Correct 128 ms 4980 KB Output is correct
5 Correct 70 ms 2952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 126 ms 5040 KB Output is correct
2 Correct 119 ms 4600 KB Output is correct
3 Correct 128 ms 4984 KB Output is correct
4 Correct 131 ms 4896 KB Output is correct
5 Correct 136 ms 5192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 128 ms 5192 KB Output is correct
2 Correct 131 ms 5032 KB Output is correct
3 Correct 125 ms 5140 KB Output is correct
4 Correct 158 ms 5560 KB Output is correct
5 Correct 135 ms 5228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 151 ms 5700 KB Output is correct
2 Correct 148 ms 5568 KB Output is correct
3 Correct 152 ms 5572 KB Output is correct
4 Correct 162 ms 5596 KB Output is correct
5 Correct 146 ms 5584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 149 ms 5560 KB Output is correct
2 Correct 156 ms 5580 KB Output is correct
3 Correct 141 ms 5536 KB Output is correct
4 Correct 186 ms 5524 KB Output is correct
5 Correct 146 ms 5580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 739 ms 24348 KB Output is correct
2 Correct 750 ms 32064 KB Output is correct
3 Correct 757 ms 31588 KB Output is correct
4 Correct 810 ms 33960 KB Output is correct
5 Correct 762 ms 31152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 774 ms 24396 KB Output is correct
2 Correct 849 ms 30908 KB Output is correct
3 Correct 776 ms 30156 KB Output is correct
4 Correct 786 ms 33796 KB Output is correct
5 Correct 789 ms 31600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 35900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 35672 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 38756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 38692 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 42008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 41820 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1100 ms 48076 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 48320 KB Time limit exceeded
2 Halted 0 ms 0 KB -