Submission #817174

# Submission time Handle Problem Language Result Execution time Memory
817174 2023-08-09T10:04:45 Z MisterReaper Mobile (BOI12_mobile) C++17
100 / 100
649 ms 30672 KB
// author: MisterReaper (Ahmet Alp Orakci)
#include <bits/stdc++.h>
using namespace std;
#define int long long

#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    #include "debug.h"
    #define OPEN freopen(".in", "r", stdin); freopen(".out", "w", stdout);
    #define TIME cerr << "\n" << fixed << setprecision(2) << 1000.0 * clock() / CLOCKS_PER_SEC << " milliseconds ";
#else
    #define debug(...) void(23)
    #define debugarr(...) void(23)
    #define OPEN void(0000)
    #define TIME void(232323233)
#endif

void solve()
{
    int n, m; cin >> n >> m;
    pair <int, int> arr[n];
    for(auto &i : arr) cin >> i.first >> i.second;

    auto check = [&](double mid) -> bool
    {
        double cur = 0;;
        for(auto &i : arr)
        {
            double delta = sqrtl(mid * mid - i.second * i.second);
            double nl = i.first - delta;
            if(nl <= cur) cur = max(cur, i.first + delta);
        }
        return ((double) m <= cur);
    };

    double l = 0, r = 1e10, res = 0;
    while((r - l) >= 1e-3)
    {
        debug(l, r);
        double mid = (l + r) / 2;
        if(check(mid))
        {
            r = mid;
            res = mid;
        }
        else l = mid;
    }

    cout << fixed << setprecision(6) << res;
    
    return;
}

int32_t main()
{
    OPEN;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int t = 1; //cin >> t;
    while(t--)
    {
        solve();
    }

    TIME;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 280 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 2 ms 464 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 4 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 4 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 1596 KB Output is correct
2 Correct 34 ms 1748 KB Output is correct
3 Correct 26 ms 1388 KB Output is correct
4 Correct 44 ms 1736 KB Output is correct
5 Correct 22 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 1648 KB Output is correct
2 Correct 47 ms 1652 KB Output is correct
3 Correct 44 ms 1828 KB Output is correct
4 Correct 56 ms 1784 KB Output is correct
5 Correct 59 ms 1908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1804 KB Output is correct
2 Correct 38 ms 1712 KB Output is correct
3 Correct 30 ms 1768 KB Output is correct
4 Correct 65 ms 1980 KB Output is correct
5 Correct 46 ms 1944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2004 KB Output is correct
2 Correct 36 ms 1988 KB Output is correct
3 Correct 40 ms 2004 KB Output is correct
4 Correct 69 ms 1984 KB Output is correct
5 Correct 53 ms 2116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2004 KB Output is correct
2 Correct 31 ms 1876 KB Output is correct
3 Correct 34 ms 1900 KB Output is correct
4 Correct 65 ms 2004 KB Output is correct
5 Correct 54 ms 2120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 141 ms 8256 KB Output is correct
2 Correct 161 ms 8252 KB Output is correct
3 Correct 152 ms 8256 KB Output is correct
4 Correct 319 ms 8252 KB Output is correct
5 Correct 271 ms 8380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 156 ms 8252 KB Output is correct
2 Correct 267 ms 8164 KB Output is correct
3 Correct 176 ms 8276 KB Output is correct
4 Correct 325 ms 8276 KB Output is correct
5 Correct 282 ms 8384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 168 ms 9820 KB Output is correct
2 Correct 192 ms 9812 KB Output is correct
3 Correct 184 ms 9828 KB Output is correct
4 Correct 388 ms 9820 KB Output is correct
5 Correct 324 ms 9944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 189 ms 9820 KB Output is correct
2 Correct 317 ms 9816 KB Output is correct
3 Correct 213 ms 9948 KB Output is correct
4 Correct 391 ms 9940 KB Output is correct
5 Correct 339 ms 9964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 201 ms 11276 KB Output is correct
2 Correct 216 ms 11384 KB Output is correct
3 Correct 215 ms 11380 KB Output is correct
4 Correct 449 ms 11380 KB Output is correct
5 Correct 383 ms 11512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 218 ms 11384 KB Output is correct
2 Correct 368 ms 11384 KB Output is correct
3 Correct 245 ms 11516 KB Output is correct
4 Correct 443 ms 11508 KB Output is correct
5 Correct 403 ms 11504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 226 ms 12884 KB Output is correct
2 Correct 248 ms 12956 KB Output is correct
3 Correct 251 ms 12944 KB Output is correct
4 Correct 537 ms 12944 KB Output is correct
5 Correct 444 ms 23988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 252 ms 12948 KB Output is correct
2 Correct 418 ms 12952 KB Output is correct
3 Correct 296 ms 13080 KB Output is correct
4 Correct 514 ms 12976 KB Output is correct
5 Correct 460 ms 24420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 289 ms 16080 KB Output is correct
2 Correct 308 ms 16084 KB Output is correct
3 Correct 304 ms 16072 KB Output is correct
4 Correct 646 ms 15956 KB Output is correct
5 Correct 554 ms 29512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 321 ms 15956 KB Output is correct
2 Correct 521 ms 16076 KB Output is correct
3 Correct 363 ms 16228 KB Output is correct
4 Correct 649 ms 15960 KB Output is correct
5 Correct 570 ms 30672 KB Output is correct