Submission #470020

# Submission time Handle Problem Language Result Execution time Memory
470020 2021-09-02T15:23:21 Z Shogun3103 Mobile (BOI12_mobile) C++17
100 / 100
553 ms 16256 KB
#include <bits/stdc++.h>
 
using namespace std;

void setIO(string fileName = ""){
    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;

int n, len;
ll2 a[N];

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

    double l = 1, r = 1.5e9;
    while(r - l > 1e-3) {
        double m = (l + r) / 2, cur = 0;
        FOR(i, 0, n - 1) {
            double delta = sqrt(m * m - a[i].Y * a[i].Y);
            double x = a[i].X - delta, y = a[i].X + delta;
            if(x <= cur) cur = max(cur, y);
        }
        if(cur >= len) r = m;
        else l = m;   
    }
    cout << fixed << setprecision(4) << l; 
}   

int main()
{ 
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);        
    //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:7:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |         freopen((fileName+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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+".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 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 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 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 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 3 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 4 ms 400 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 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1484 KB Output is correct
2 Correct 31 ms 1416 KB Output is correct
3 Correct 21 ms 1100 KB Output is correct
4 Correct 38 ms 1440 KB Output is correct
5 Correct 20 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1484 KB Output is correct
2 Correct 33 ms 1408 KB Output is correct
3 Correct 39 ms 1568 KB Output is correct
4 Correct 40 ms 1424 KB Output is correct
5 Correct 56 ms 1604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1672 KB Output is correct
2 Correct 34 ms 1516 KB Output is correct
3 Correct 37 ms 1612 KB Output is correct
4 Correct 53 ms 1852 KB Output is correct
5 Correct 43 ms 1696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 1832 KB Output is correct
2 Correct 42 ms 1760 KB Output is correct
3 Correct 40 ms 1880 KB Output is correct
4 Correct 57 ms 1864 KB Output is correct
5 Correct 47 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 1860 KB Output is correct
2 Correct 42 ms 1788 KB Output is correct
3 Correct 41 ms 1872 KB Output is correct
4 Correct 55 ms 1748 KB Output is correct
5 Correct 48 ms 1756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 182 ms 8124 KB Output is correct
2 Correct 206 ms 8124 KB Output is correct
3 Correct 207 ms 8020 KB Output is correct
4 Correct 264 ms 8132 KB Output is correct
5 Correct 240 ms 8100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 217 ms 8080 KB Output is correct
2 Correct 280 ms 8128 KB Output is correct
3 Correct 203 ms 8132 KB Output is correct
4 Correct 258 ms 8136 KB Output is correct
5 Correct 241 ms 8124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 223 ms 9784 KB Output is correct
2 Correct 284 ms 9668 KB Output is correct
3 Correct 245 ms 9648 KB Output is correct
4 Correct 324 ms 9796 KB Output is correct
5 Correct 284 ms 9668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 257 ms 9768 KB Output is correct
2 Correct 333 ms 9752 KB Output is correct
3 Correct 240 ms 9608 KB Output is correct
4 Correct 314 ms 9776 KB Output is correct
5 Correct 282 ms 9668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 261 ms 11204 KB Output is correct
2 Correct 294 ms 11260 KB Output is correct
3 Correct 287 ms 11204 KB Output is correct
4 Correct 383 ms 11252 KB Output is correct
5 Correct 332 ms 11220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 327 ms 11204 KB Output is correct
2 Correct 387 ms 11256 KB Output is correct
3 Correct 305 ms 11264 KB Output is correct
4 Correct 372 ms 11260 KB Output is correct
5 Correct 332 ms 11256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 305 ms 12824 KB Output is correct
2 Correct 399 ms 12824 KB Output is correct
3 Correct 325 ms 12724 KB Output is correct
4 Correct 425 ms 12720 KB Output is correct
5 Correct 383 ms 12872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 334 ms 12824 KB Output is correct
2 Correct 437 ms 12912 KB Output is correct
3 Correct 323 ms 12824 KB Output is correct
4 Correct 420 ms 12856 KB Output is correct
5 Correct 377 ms 12828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 380 ms 16068 KB Output is correct
2 Correct 414 ms 15940 KB Output is correct
3 Correct 411 ms 15940 KB Output is correct
4 Correct 524 ms 15940 KB Output is correct
5 Correct 480 ms 16256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 417 ms 15932 KB Output is correct
2 Correct 539 ms 15932 KB Output is correct
3 Correct 415 ms 15924 KB Output is correct
4 Correct 553 ms 15948 KB Output is correct
5 Correct 517 ms 16188 KB Output is correct