Submission #470004

# Submission time Handle Problem Language Result Execution time Memory
470004 2021-09-02T15:01:09 Z Shogun3103 Mobile (BOI12_mobile) C++17
90 / 100
1000 ms 28536 KB
#include <bits/stdc++.h>
 
using namespace std;

void setIO(string fileName = ""){
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);        
    if(fileName.length()){
        freopen((fileName+".in").c_str(), "r", stdin);
        freopen((fileName+".out").c_str(), "w", stdout);
    }
}

#define ll long long
#define ld long double
#define FOR(i,a,b) for(__typeof(b) i=a; i<=b; i++)
#define FOD(i,a,b) for(__typeof(b) i=b; i>=a; i--)
#define EACH(u, v) for(auto& u : v)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,ii>
#define ld2 pair<ld, ld>
#define ll2 pair<ll, ll>
#define X first
#define Y second
#define ed "\n"
#define sp " "
const int oo = 1e9 + 7;
const int N = 1e6 + 10;

int n, len;
ll2 a[N];
ld cur;

bool calc(ld x)
{   
    FOR(i, 1, n) {
        ld delta = sqrt(x * x - a[i].Y * a[i].Y);
        ld x = a[i].X - delta, y = a[i].X + delta;
        if(x <= cur) cur = max(cur, y);
    }   
    return cur >= len;
}

void solve()
{
    cin >> n >> len;
    FOR(i, 1, n) cin >> a[i].X >> a[i].Y;

    ld l = 1, r = 1.5e9;
    while(l <= r) {
        ld m = (l + r) * 0.5;
        cur = 0;
        if(calc(m)) {
            r = m - 0.0001;
        } else {
            l = m + 0.0001;
        }
    }
    cout << fixed << setprecision(6) << r; 
}   

int main()
{ 
    setIO("");
    int t; 
    t = 1;
    //cin >> t;
    FOR(i, 1, t) {
        solve();
    }
    return 0;
}

Compilation message

mobile.cpp: In function 'void setIO(std::string)':
mobile.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen((fileName+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:9:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         freopen((fileName+".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 2 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 7 ms 400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 6 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 8 ms 460 KB Output is correct
5 Correct 5 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 1612 KB Output is correct
2 Correct 51 ms 1628 KB Output is correct
3 Correct 39 ms 1844 KB Output is correct
4 Correct 90 ms 2644 KB Output is correct
5 Correct 47 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 1656 KB Output is correct
2 Correct 71 ms 1524 KB Output is correct
3 Correct 84 ms 1604 KB Output is correct
4 Correct 83 ms 2748 KB Output is correct
5 Correct 95 ms 3212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 1740 KB Output is correct
2 Correct 54 ms 1716 KB Output is correct
3 Correct 65 ms 2588 KB Output is correct
4 Correct 117 ms 3920 KB Output is correct
5 Correct 84 ms 2616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 1940 KB Output is correct
2 Correct 72 ms 1940 KB Output is correct
3 Correct 73 ms 2892 KB Output is correct
4 Correct 117 ms 3820 KB Output is correct
5 Correct 100 ms 3132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 1996 KB Output is correct
2 Correct 65 ms 1896 KB Output is correct
3 Correct 74 ms 2896 KB Output is correct
4 Correct 115 ms 3808 KB Output is correct
5 Correct 100 ms 3092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 362 ms 8252 KB Output is correct
2 Correct 315 ms 8260 KB Output is correct
3 Correct 343 ms 15340 KB Output is correct
4 Correct 572 ms 17756 KB Output is correct
5 Correct 512 ms 14920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 332 ms 8156 KB Output is correct
2 Correct 513 ms 14728 KB Output is correct
3 Correct 393 ms 13872 KB Output is correct
4 Correct 568 ms 16628 KB Output is correct
5 Correct 521 ms 15300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 428 ms 9820 KB Output is correct
2 Correct 400 ms 10208 KB Output is correct
3 Correct 419 ms 18252 KB Output is correct
4 Correct 753 ms 18132 KB Output is correct
5 Correct 643 ms 17672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 408 ms 10152 KB Output is correct
2 Correct 618 ms 17672 KB Output is correct
3 Correct 472 ms 16528 KB Output is correct
4 Correct 686 ms 18364 KB Output is correct
5 Correct 622 ms 18372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 501 ms 11516 KB Output is correct
2 Correct 468 ms 11844 KB Output is correct
3 Correct 490 ms 19908 KB Output is correct
4 Correct 799 ms 19876 KB Output is correct
5 Correct 705 ms 19908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 470 ms 11644 KB Output is correct
2 Correct 693 ms 19780 KB Output is correct
3 Correct 512 ms 19652 KB Output is correct
4 Correct 790 ms 19808 KB Output is correct
5 Correct 730 ms 19736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 576 ms 12996 KB Output is correct
2 Correct 523 ms 13124 KB Output is correct
3 Correct 539 ms 24516 KB Output is correct
4 Correct 918 ms 28536 KB Output is correct
5 Correct 838 ms 24128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 525 ms 13284 KB Output is correct
2 Correct 806 ms 21316 KB Output is correct
3 Correct 593 ms 21412 KB Output is correct
4 Correct 919 ms 21336 KB Output is correct
5 Correct 841 ms 21380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 710 ms 16328 KB Output is correct
2 Correct 696 ms 16472 KB Output is correct
3 Correct 648 ms 24600 KB Output is correct
4 Execution timed out 1090 ms 16328 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 644 ms 16336 KB Output is correct
2 Execution timed out 1006 ms 24608 KB Time limit exceeded
3 Halted 0 ms 0 KB -