Submission #1093063

# Submission time Handle Problem Language Result Execution time Memory
1093063 2024-09-25T19:04:55 Z TommasoUlian Mobile (BOI12_mobile) C++14
100 / 100
449 ms 25936 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
vector<pair<double, double>> torri;
ll n, L;

bool good(double r) {
    queue<pair<double, double>> s;
    double curr = 0;
    for (auto a : torri) {
        double x = a.first, y = a.second;
        if(curr >= L)return true;
        if (abs(y) <= r - 1e-6) { 
            double dx = sqrt((r + y) * (r - y));
            double a = x-dx, b = x+dx;
            if(a-1e-6 <= curr){
                curr = max(b,curr);
            }
        }
    }

    
    return curr >= L; 
}

void solve() {
    cin >> n >> L;
    torri.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> torri[i].first >> torri[i].second;
    }

    double l = 1, r = 2e9; 
    double ans = r;

    while (r - l > 1e-4) { 
        double c = (r + l) / 2;
        if (good(c)) {
            ans = c;
            r = c;
        } else {
            l = c;
        }
    }

    cout << setprecision(18) << (l + r) / 2 << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    solve();
    return 0;
}

Compilation message

mobile.cpp: In function 'void solve()':
mobile.cpp:35:12: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   35 |     double ans = r;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 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 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 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 2 ms 348 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 576 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 604 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2396 KB Output is correct
2 Correct 27 ms 2284 KB Output is correct
3 Correct 18 ms 1880 KB Output is correct
4 Correct 29 ms 2360 KB Output is correct
5 Correct 14 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 2140 KB Output is correct
2 Correct 23 ms 2136 KB Output is correct
3 Correct 28 ms 2496 KB Output is correct
4 Correct 28 ms 2452 KB Output is correct
5 Correct 33 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 2336 KB Output is correct
2 Correct 31 ms 2396 KB Output is correct
3 Correct 27 ms 2396 KB Output is correct
4 Correct 38 ms 3164 KB Output is correct
5 Correct 26 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 2896 KB Output is correct
2 Correct 38 ms 2908 KB Output is correct
3 Correct 30 ms 2648 KB Output is correct
4 Correct 38 ms 3160 KB Output is correct
5 Correct 31 ms 2904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 2904 KB Output is correct
2 Correct 35 ms 2928 KB Output is correct
3 Correct 30 ms 2652 KB Output is correct
4 Correct 38 ms 3160 KB Output is correct
5 Correct 33 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 181 ms 10836 KB Output is correct
2 Correct 195 ms 12540 KB Output is correct
3 Correct 171 ms 12372 KB Output is correct
4 Correct 204 ms 13652 KB Output is correct
5 Correct 173 ms 11728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 198 ms 12880 KB Output is correct
2 Correct 228 ms 11860 KB Output is correct
3 Correct 153 ms 11228 KB Output is correct
4 Correct 178 ms 13136 KB Output is correct
5 Correct 163 ms 12112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 225 ms 12760 KB Output is correct
2 Correct 202 ms 14928 KB Output is correct
3 Correct 201 ms 14408 KB Output is correct
4 Correct 234 ms 15968 KB Output is correct
5 Correct 200 ms 14164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 236 ms 15116 KB Output is correct
2 Correct 264 ms 14164 KB Output is correct
3 Correct 211 ms 13404 KB Output is correct
4 Correct 214 ms 15984 KB Output is correct
5 Correct 191 ms 14444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 251 ms 14772 KB Output is correct
2 Correct 244 ms 17232 KB Output is correct
3 Correct 236 ms 16640 KB Output is correct
4 Correct 277 ms 18316 KB Output is correct
5 Correct 226 ms 16208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 279 ms 17492 KB Output is correct
2 Correct 313 ms 16360 KB Output is correct
3 Correct 242 ms 15696 KB Output is correct
4 Correct 265 ms 18516 KB Output is correct
5 Correct 240 ms 16784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 319 ms 16824 KB Output is correct
2 Correct 310 ms 19536 KB Output is correct
3 Correct 283 ms 19104 KB Output is correct
4 Correct 300 ms 21076 KB Output is correct
5 Correct 267 ms 18712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 330 ms 19736 KB Output is correct
2 Correct 355 ms 18520 KB Output is correct
3 Correct 262 ms 18000 KB Output is correct
4 Correct 279 ms 20764 KB Output is correct
5 Correct 264 ms 19028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 353 ms 20564 KB Output is correct
2 Correct 339 ms 24108 KB Output is correct
3 Correct 341 ms 23400 KB Output is correct
4 Correct 353 ms 25684 KB Output is correct
5 Correct 339 ms 22868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 433 ms 24952 KB Output is correct
2 Correct 449 ms 23052 KB Output is correct
3 Correct 320 ms 22356 KB Output is correct
4 Correct 374 ms 25936 KB Output is correct
5 Correct 331 ms 23636 KB Output is correct