Submission #1100989

# Submission time Handle Problem Language Result Execution time Memory
1100989 2024-10-15T07:56:15 Z hoangteo0103 Mobile (BOI12_mobile) C++17
100 / 100
734 ms 35400 KB
#include "bits/stdc++.h"
using namespace std;
void setIO(string s){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    if(fopen("trash.in", "r"))
	freopen("trash.in", "r", stdin) , freopen("trash.out", "w", stdout);
}
int main(){
    setIO("hoangteo0103");

    int n, len;
    cin >> n >> len;
    vector<array<double, 2>> a(n);
    for(int i = 0 ; i < n ; i++) cin >> a[i][0] >> a[i][1];

    double ans;

    auto check = [&](double lim) -> bool {
        double prev = 0;
        for(int i = 0 ; i < n ; i++) {
            double edge = sqrt(lim * lim - a[i][1] * a[i][1]) ;
            double l = a[i][0] - edge, r = a[i][0] + edge;
            if(l <= prev)  prev = max(prev, r);
         }
         return prev >= len;
    };
    double l = 0, r = 1.5e9;

    while(r - l > 1e-6) {
        double mid = (l+r)/2;

        if(check(mid)) {
            ans = mid ;
            r = mid;
        } else {
            l = mid;
        }
    }

    cout << fixed << setprecision(6) << ans;
}



Compilation message

mobile.cpp: In function 'void setIO(std::string)':
mobile.cpp:7:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  freopen("trash.in", "r", stdin) , freopen("trash.out", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:7:43: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  freopen("trash.in", "r", stdin) , freopen("trash.out", "w", stdout);
      |                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 340 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 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 760 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 4 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 4 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 3 ms 584 KB Output is correct
4 Correct 5 ms 484 KB Output is correct
5 Correct 3 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 2400 KB Output is correct
2 Correct 34 ms 2680 KB Output is correct
3 Correct 24 ms 1888 KB Output is correct
4 Correct 42 ms 2656 KB Output is correct
5 Correct 23 ms 1632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 2368 KB Output is correct
2 Correct 38 ms 2144 KB Output is correct
3 Correct 40 ms 2752 KB Output is correct
4 Correct 44 ms 2904 KB Output is correct
5 Correct 50 ms 3076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2460 KB Output is correct
2 Correct 36 ms 2900 KB Output is correct
3 Correct 37 ms 2644 KB Output is correct
4 Correct 59 ms 3792 KB Output is correct
5 Correct 45 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 3412 KB Output is correct
2 Correct 41 ms 3404 KB Output is correct
3 Correct 40 ms 2912 KB Output is correct
4 Correct 61 ms 3924 KB Output is correct
5 Correct 50 ms 3152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 3428 KB Output is correct
2 Correct 41 ms 3416 KB Output is correct
3 Correct 40 ms 2900 KB Output is correct
4 Correct 57 ms 3924 KB Output is correct
5 Correct 49 ms 3292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 175 ms 12492 KB Output is correct
2 Correct 205 ms 15944 KB Output is correct
3 Correct 196 ms 15320 KB Output is correct
4 Correct 272 ms 17628 KB Output is correct
5 Correct 250 ms 14952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 205 ms 16476 KB Output is correct
2 Correct 330 ms 14680 KB Output is correct
3 Correct 212 ms 13912 KB Output is correct
4 Correct 279 ms 17476 KB Output is correct
5 Correct 257 ms 15444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 240 ms 14820 KB Output is correct
2 Correct 266 ms 19016 KB Output is correct
3 Correct 248 ms 18504 KB Output is correct
4 Correct 345 ms 21584 KB Output is correct
5 Correct 311 ms 17748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 267 ms 19684 KB Output is correct
2 Correct 358 ms 17740 KB Output is correct
3 Correct 251 ms 16456 KB Output is correct
4 Correct 348 ms 21580 KB Output is correct
5 Correct 323 ms 18508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 276 ms 17228 KB Output is correct
2 Correct 293 ms 22088 KB Output is correct
3 Correct 293 ms 21580 KB Output is correct
4 Correct 404 ms 24716 KB Output is correct
5 Correct 354 ms 20232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 288 ms 22864 KB Output is correct
2 Correct 410 ms 20620 KB Output is correct
3 Correct 285 ms 19796 KB Output is correct
4 Correct 415 ms 24716 KB Output is correct
5 Correct 350 ms 21320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 281 ms 19788 KB Output is correct
2 Correct 317 ms 25160 KB Output is correct
3 Correct 320 ms 24360 KB Output is correct
4 Correct 448 ms 28492 KB Output is correct
5 Correct 408 ms 23976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 345 ms 25932 KB Output is correct
2 Correct 451 ms 23372 KB Output is correct
3 Correct 341 ms 22348 KB Output is correct
4 Correct 461 ms 28500 KB Output is correct
5 Correct 428 ms 24368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 377 ms 24652 KB Output is correct
2 Correct 428 ms 31460 KB Output is correct
3 Correct 425 ms 30536 KB Output is correct
4 Correct 594 ms 35144 KB Output is correct
5 Correct 501 ms 29536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 426 ms 32592 KB Output is correct
2 Correct 585 ms 29284 KB Output is correct
3 Correct 417 ms 28256 KB Output is correct
4 Correct 734 ms 35400 KB Output is correct
5 Correct 512 ms 30812 KB Output is correct