Submission #1026868

# Submission time Handle Problem Language Result Execution time Memory
1026868 2024-07-18T12:32:07 Z PooyaDaftarian Mobile (BOI12_mobile) C++17
100 / 100
611 ms 35412 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef double ld;

#define all(x) x.begin(), x.end()
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL)
#define file(x) freopen(x ".in", "r", stdin); freopen(x ".out", "w", stdout)
#define endl '\n'
#define pb push_back
#define ms(x, y) memset(x, y, sizeof x)
#define out(x) {cout << x << '\n'; return;}
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define int ll

int n, L;
vector<pair<ld, ld>> a;

bool chk(ld x){
    ld mx = 0;
    for (int i = 0 ; i < n ; i++){
        ld d = sqrt(x*x - a[i].ss*a[i].ss);
        ld x = a[i].ff - d, y = a[i].ff + d;
        if (x <= mx) mx = max(mx, y);
    }
    return (mx < L);
}

int32_t main(){
    fast_io;
    cout << fixed << setprecision(6);
	cin >> n >> L;
    a.assign(n, {0.0, 0.0});
    for (int i = 0 ; i < n ; i++){
        ld x, h; cin >> x >> h;
        a[i] = {x, h};
    }
    ld l = 0, r = 1e10, mid;
    for (int i = 0 ; i < 60 ; i++){
        mid = l + (r-l)/2;
        if (chk(mid)) l = mid;
        else r = mid;
    }
    cout << l << endl;
    return 0;
}
# Verdict Execution time Memory 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 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 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 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 3 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 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 1628 KB Output is correct
2 Correct 41 ms 1628 KB Output is correct
3 Correct 24 ms 1116 KB Output is correct
4 Correct 41 ms 1628 KB Output is correct
5 Correct 31 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 1628 KB Output is correct
2 Correct 36 ms 1372 KB Output is correct
3 Correct 43 ms 1628 KB Output is correct
4 Correct 43 ms 1628 KB Output is correct
5 Correct 48 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 1624 KB Output is correct
2 Correct 37 ms 1628 KB Output is correct
3 Correct 32 ms 1628 KB Output is correct
4 Correct 50 ms 1880 KB Output is correct
5 Correct 38 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1884 KB Output is correct
2 Correct 40 ms 1884 KB Output is correct
3 Correct 37 ms 1880 KB Output is correct
4 Correct 49 ms 1880 KB Output is correct
5 Correct 54 ms 1880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1880 KB Output is correct
2 Correct 39 ms 1884 KB Output is correct
3 Correct 36 ms 1884 KB Output is correct
4 Correct 50 ms 1884 KB Output is correct
5 Correct 46 ms 1880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 174 ms 8280 KB Output is correct
2 Correct 190 ms 8280 KB Output is correct
3 Correct 218 ms 8284 KB Output is correct
4 Correct 259 ms 8284 KB Output is correct
5 Correct 266 ms 8280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 196 ms 8280 KB Output is correct
2 Correct 291 ms 8284 KB Output is correct
3 Correct 201 ms 8284 KB Output is correct
4 Correct 255 ms 8284 KB Output is correct
5 Correct 239 ms 8284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 219 ms 9820 KB Output is correct
2 Correct 244 ms 9820 KB Output is correct
3 Correct 251 ms 9816 KB Output is correct
4 Correct 371 ms 9820 KB Output is correct
5 Correct 296 ms 9816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 239 ms 9816 KB Output is correct
2 Correct 363 ms 9820 KB Output is correct
3 Correct 267 ms 9820 KB Output is correct
4 Correct 329 ms 9816 KB Output is correct
5 Correct 378 ms 18544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 281 ms 11356 KB Output is correct
2 Correct 313 ms 11356 KB Output is correct
3 Correct 313 ms 11608 KB Output is correct
4 Correct 408 ms 11356 KB Output is correct
5 Correct 372 ms 20308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 317 ms 11352 KB Output is correct
2 Correct 451 ms 11352 KB Output is correct
3 Correct 310 ms 11352 KB Output is correct
4 Correct 400 ms 11356 KB Output is correct
5 Correct 384 ms 21452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 327 ms 12888 KB Output is correct
2 Correct 369 ms 12888 KB Output is correct
3 Correct 413 ms 12892 KB Output is correct
4 Correct 525 ms 12892 KB Output is correct
5 Correct 413 ms 24096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 367 ms 12896 KB Output is correct
2 Correct 502 ms 12888 KB Output is correct
3 Correct 393 ms 22316 KB Output is correct
4 Correct 514 ms 28340 KB Output is correct
5 Correct 463 ms 24484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 388 ms 15964 KB Output is correct
2 Correct 407 ms 15964 KB Output is correct
3 Correct 436 ms 15960 KB Output is correct
4 Correct 611 ms 15964 KB Output is correct
5 Correct 542 ms 29444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 394 ms 15964 KB Output is correct
2 Correct 591 ms 15964 KB Output is correct
3 Correct 433 ms 28244 KB Output is correct
4 Correct 566 ms 35412 KB Output is correct
5 Correct 586 ms 30804 KB Output is correct