Submission #964058

# Submission time Handle Problem Language Result Execution time Memory
964058 2024-04-16T09:04:17 Z Neco_arc Mobile (BOI12_mobile) C++17
100 / 100
697 ms 30856 KB
#include <bits/stdc++.h>

#define ll long long
#define all(x) x.begin(), x.end()
#define Neco "Mobile"
#define resp(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define getbit(x,i) ((x >> i)&1)
#define _left id * 2, l, mid
#define _right id * 2 + 1, mid + 1, r
#define cntbit(x) __builtin_popcountll(x)
#define fi(i, a, b) for(int i = a; i <= b; i++)
#define fid(i, a, b) for(int i = a; i >= b; i--)
#define maxn (int) 1e6 + 7

using namespace std;

const ll mod = 1e9 + 7; //972663749
const ll base = 911382323;
typedef double ld;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll GetRandom(ll l, ll r)
{
    return uniform_int_distribution<ll> (l, r)(rng);
}

int n, L;
pair<ld, ld> a[maxn];

void solve()
{

    cin >> n >> L;
    fi(i, 1, n) cin >> a[i].first >> a[i].second;

    ld l = 1, r = 1.5e9;
    while(r - l > 1e-3)
    {
        ld mid = (l + r) / 2;

        ld Curr = 0;
        fi(i, 1, n) {
            ld L, R;
            if(mid < a[i].second) L = R = 0;
            else {
                ld len = sqrt( (mid * mid) - (a[i].second * a[i].second) );
                L = a[i].first - len, R = a[i].first + len;
            }
            if(Curr >= L) Curr = max(Curr, R);
        }

        if(Curr >= L) r = mid;
        else l = mid;
    }

    cout << fixed << setprecision(5) << r;

}


int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    if(fopen(Neco".inp", "r")) {
        freopen(Neco".inp", "r", stdin);
        freopen(Neco".out", "w", stdout);
    }


    int nTest = 1;
//    cin >> nTest;


    while(nTest--)
    {
        solve();
    }


    return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:70:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |         freopen(Neco".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:71:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         freopen(Neco".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 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 500 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 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 3 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 348 KB Output is correct
2 Correct 3 ms 532 KB Output is correct
3 Correct 3 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 35 ms 2668 KB Output is correct
2 Correct 35 ms 2648 KB Output is correct
3 Correct 23 ms 2648 KB Output is correct
4 Correct 47 ms 2676 KB Output is correct
5 Correct 21 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2672 KB Output is correct
2 Correct 40 ms 2668 KB Output is correct
3 Correct 48 ms 2652 KB Output is correct
4 Correct 50 ms 2900 KB Output is correct
5 Correct 56 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2652 KB Output is correct
2 Correct 39 ms 2616 KB Output is correct
3 Correct 36 ms 2648 KB Output is correct
4 Correct 74 ms 2652 KB Output is correct
5 Correct 52 ms 2672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 2652 KB Output is correct
2 Correct 46 ms 2672 KB Output is correct
3 Correct 41 ms 2904 KB Output is correct
4 Correct 72 ms 2668 KB Output is correct
5 Correct 58 ms 2672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 2652 KB Output is correct
2 Correct 48 ms 2668 KB Output is correct
3 Correct 42 ms 2676 KB Output is correct
4 Correct 68 ms 2668 KB Output is correct
5 Correct 58 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 219 ms 8824 KB Output is correct
2 Correct 237 ms 8824 KB Output is correct
3 Correct 226 ms 8580 KB Output is correct
4 Correct 338 ms 8828 KB Output is correct
5 Correct 310 ms 8828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 236 ms 8832 KB Output is correct
2 Correct 265 ms 9280 KB Output is correct
3 Correct 219 ms 8836 KB Output is correct
4 Correct 336 ms 8828 KB Output is correct
5 Correct 305 ms 8784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 264 ms 10876 KB Output is correct
2 Correct 281 ms 10864 KB Output is correct
3 Correct 283 ms 10836 KB Output is correct
4 Correct 419 ms 10880 KB Output is correct
5 Correct 390 ms 10884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 306 ms 10884 KB Output is correct
2 Correct 303 ms 10880 KB Output is correct
3 Correct 285 ms 10888 KB Output is correct
4 Correct 426 ms 10836 KB Output is correct
5 Correct 370 ms 10884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 287 ms 12932 KB Output is correct
2 Correct 349 ms 12932 KB Output is correct
3 Correct 325 ms 12884 KB Output is correct
4 Correct 479 ms 12928 KB Output is correct
5 Correct 401 ms 12912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 329 ms 12884 KB Output is correct
2 Correct 345 ms 12932 KB Output is correct
3 Correct 304 ms 13184 KB Output is correct
4 Correct 473 ms 12932 KB Output is correct
5 Correct 441 ms 12884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 326 ms 14960 KB Output is correct
2 Correct 370 ms 14932 KB Output is correct
3 Correct 374 ms 15188 KB Output is correct
4 Correct 547 ms 14980 KB Output is correct
5 Correct 511 ms 14972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 381 ms 14928 KB Output is correct
2 Correct 388 ms 14936 KB Output is correct
3 Correct 359 ms 14980 KB Output is correct
4 Correct 547 ms 14992 KB Output is correct
5 Correct 489 ms 15232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 407 ms 15988 KB Output is correct
2 Correct 457 ms 16212 KB Output is correct
3 Correct 481 ms 16092 KB Output is correct
4 Correct 666 ms 15956 KB Output is correct
5 Correct 607 ms 29664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 491 ms 15972 KB Output is correct
2 Correct 514 ms 16092 KB Output is correct
3 Correct 432 ms 15996 KB Output is correct
4 Correct 697 ms 16212 KB Output is correct
5 Correct 623 ms 30856 KB Output is correct