Submission #466086

# Submission time Handle Problem Language Result Execution time Memory
466086 2021-08-17T21:58:56 Z joshualiu555 Mobile (BOI12_mobile) C++14
50 / 100
1000 ms 48188 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 < 100; 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 0 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 5 ms 460 KB Output is correct
2 Correct 5 ms 460 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 4 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 604 KB Output is correct
2 Correct 11 ms 604 KB Output is correct
3 Correct 11 ms 608 KB Output is correct
4 Correct 12 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 604 KB Output is correct
2 Correct 11 ms 604 KB Output is correct
3 Correct 11 ms 620 KB Output is correct
4 Correct 12 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 604 KB Output is correct
2 Correct 12 ms 620 KB Output is correct
3 Correct 11 ms 608 KB Output is correct
4 Correct 12 ms 604 KB Output is correct
5 Correct 11 ms 616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 260 ms 4812 KB Output is correct
2 Correct 223 ms 4880 KB Output is correct
3 Correct 140 ms 3036 KB Output is correct
4 Correct 235 ms 5140 KB Output is correct
5 Correct 134 ms 3016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 233 ms 4932 KB Output is correct
2 Correct 226 ms 4724 KB Output is correct
3 Correct 243 ms 5044 KB Output is correct
4 Correct 269 ms 5020 KB Output is correct
5 Correct 266 ms 5636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 248 ms 5276 KB Output is correct
2 Correct 234 ms 5072 KB Output is correct
3 Correct 288 ms 5128 KB Output is correct
4 Correct 276 ms 5660 KB Output is correct
5 Correct 270 ms 5196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 268 ms 5632 KB Output is correct
2 Correct 276 ms 5732 KB Output is correct
3 Correct 264 ms 5720 KB Output is correct
4 Correct 303 ms 5576 KB Output is correct
5 Correct 271 ms 5676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 280 ms 5548 KB Output is correct
2 Correct 268 ms 5600 KB Output is correct
3 Correct 312 ms 5564 KB Output is correct
4 Correct 274 ms 5576 KB Output is correct
5 Correct 306 ms 5792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 24468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 24432 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 35720 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 35720 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 38700 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 38692 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 41884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 41876 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 48128 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 48188 KB Time limit exceeded
2 Halted 0 ms 0 KB -