Submission #470011

# Submission time Handle Problem Language Result Execution time Memory
470011 2021-09-02T15:05:36 Z Shogun3103 Mobile (BOI12_mobile) C++17
90 / 100
1000 ms 24716 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(r - l > 1e-3) {
        ld m = (l + r) * 0.5;
        cur = 0;
        if(calc(m)) {
            r = m - 0.0001;
        } else {
            l = m + 0.0001;
        }
    }
    cout << fixed << setprecision(4) << l; 
}   

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 1 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 0 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 216 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 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 5 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 4 ms 392 KB Output is correct
4 Correct 5 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 6 ms 396 KB Output is correct
5 Correct 5 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 1476 KB Output is correct
2 Correct 49 ms 1456 KB Output is correct
3 Correct 44 ms 1156 KB Output is correct
4 Correct 79 ms 1476 KB Output is correct
5 Correct 42 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 1612 KB Output is correct
2 Correct 69 ms 1308 KB Output is correct
3 Correct 78 ms 1580 KB Output is correct
4 Correct 83 ms 1484 KB Output is correct
5 Correct 98 ms 1748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 1652 KB Output is correct
2 Correct 52 ms 1588 KB Output is correct
3 Correct 61 ms 1636 KB Output is correct
4 Correct 109 ms 1856 KB Output is correct
5 Correct 82 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 1860 KB Output is correct
2 Correct 66 ms 1856 KB Output is correct
3 Correct 70 ms 1780 KB Output is correct
4 Correct 110 ms 1800 KB Output is correct
5 Correct 95 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 80 ms 1880 KB Output is correct
2 Correct 63 ms 1860 KB Output is correct
3 Correct 72 ms 1868 KB Output is correct
4 Correct 110 ms 1864 KB Output is correct
5 Correct 96 ms 1820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 347 ms 8004 KB Output is correct
2 Correct 296 ms 8124 KB Output is correct
3 Correct 315 ms 8004 KB Output is correct
4 Correct 573 ms 8084 KB Output is correct
5 Correct 486 ms 8124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 317 ms 8132 KB Output is correct
2 Correct 474 ms 8128 KB Output is correct
3 Correct 349 ms 8132 KB Output is correct
4 Correct 545 ms 8212 KB Output is correct
5 Correct 501 ms 8236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 408 ms 9844 KB Output is correct
2 Correct 383 ms 9664 KB Output is correct
3 Correct 388 ms 9724 KB Output is correct
4 Correct 658 ms 9692 KB Output is correct
5 Correct 600 ms 9696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 377 ms 9664 KB Output is correct
2 Correct 597 ms 9692 KB Output is correct
3 Correct 430 ms 9696 KB Output is correct
4 Correct 664 ms 9764 KB Output is correct
5 Correct 597 ms 9668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 476 ms 11204 KB Output is correct
2 Correct 457 ms 11204 KB Output is correct
3 Correct 459 ms 11204 KB Output is correct
4 Correct 780 ms 11332 KB Output is correct
5 Correct 674 ms 11264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 448 ms 11264 KB Output is correct
2 Correct 663 ms 11260 KB Output is correct
3 Correct 494 ms 11332 KB Output is correct
4 Correct 768 ms 11204 KB Output is correct
5 Correct 731 ms 11256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 544 ms 12868 KB Output is correct
2 Correct 510 ms 12828 KB Output is correct
3 Correct 490 ms 12828 KB Output is correct
4 Correct 894 ms 12868 KB Output is correct
5 Correct 781 ms 12824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 508 ms 12740 KB Output is correct
2 Correct 770 ms 12868 KB Output is correct
3 Correct 605 ms 12820 KB Output is correct
4 Correct 877 ms 12868 KB Output is correct
5 Correct 804 ms 12720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 723 ms 15948 KB Output is correct
2 Correct 681 ms 16068 KB Output is correct
3 Correct 617 ms 15964 KB Output is correct
4 Execution timed out 1104 ms 16012 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 615 ms 15972 KB Output is correct
2 Correct 977 ms 15948 KB Output is correct
3 Correct 748 ms 24716 KB Output is correct
4 Execution timed out 1083 ms 16252 KB Time limit exceeded
5 Halted 0 ms 0 KB -