Submission #470019

# Submission time Handle Problem Language Result Execution time Memory
470019 2021-09-02T15:21:16 Z Shogun3103 Mobile (BOI12_mobile) C++17
90 / 100
1000 ms 16136 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;

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()
{ 
    //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 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 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 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 6 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 5 ms 368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Correct 6 ms 332 KB Output is correct
4 Correct 7 ms 360 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 1480 KB Output is correct
2 Correct 72 ms 1432 KB Output is correct
3 Correct 43 ms 1048 KB Output is correct
4 Correct 75 ms 1348 KB Output is correct
5 Correct 36 ms 1008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 1508 KB Output is correct
2 Correct 66 ms 1420 KB Output is correct
3 Correct 75 ms 1540 KB Output is correct
4 Correct 78 ms 1520 KB Output is correct
5 Correct 90 ms 1568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 1604 KB Output is correct
2 Correct 72 ms 1476 KB Output is correct
3 Correct 75 ms 1592 KB Output is correct
4 Correct 112 ms 1836 KB Output is correct
5 Correct 74 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 117 ms 1900 KB Output is correct
2 Correct 96 ms 1828 KB Output is correct
3 Correct 78 ms 1732 KB Output is correct
4 Correct 118 ms 1764 KB Output is correct
5 Correct 112 ms 1812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 1732 KB Output is correct
2 Correct 92 ms 1776 KB Output is correct
3 Correct 80 ms 1792 KB Output is correct
4 Correct 119 ms 1732 KB Output is correct
5 Correct 94 ms 1740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 358 ms 8024 KB Output is correct
2 Correct 464 ms 8104 KB Output is correct
3 Correct 438 ms 8004 KB Output is correct
4 Correct 611 ms 8104 KB Output is correct
5 Correct 473 ms 8260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 494 ms 8108 KB Output is correct
2 Correct 506 ms 8008 KB Output is correct
3 Correct 413 ms 8040 KB Output is correct
4 Correct 555 ms 8124 KB Output is correct
5 Correct 493 ms 8196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 429 ms 9724 KB Output is correct
2 Correct 613 ms 9788 KB Output is correct
3 Correct 597 ms 9612 KB Output is correct
4 Correct 738 ms 9796 KB Output is correct
5 Correct 551 ms 9672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 568 ms 9556 KB Output is correct
2 Correct 633 ms 9660 KB Output is correct
3 Correct 481 ms 9648 KB Output is correct
4 Correct 709 ms 9728 KB Output is correct
5 Correct 585 ms 9672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 560 ms 11204 KB Output is correct
2 Correct 666 ms 11332 KB Output is correct
3 Correct 637 ms 11212 KB Output is correct
4 Correct 849 ms 11296 KB Output is correct
5 Correct 652 ms 11224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 667 ms 11248 KB Output is correct
2 Correct 716 ms 11236 KB Output is correct
3 Correct 596 ms 11204 KB Output is correct
4 Correct 791 ms 11220 KB Output is correct
5 Correct 681 ms 11248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 570 ms 12748 KB Output is correct
2 Correct 786 ms 12868 KB Output is correct
3 Correct 729 ms 12800 KB Output is correct
4 Correct 960 ms 12840 KB Output is correct
5 Correct 805 ms 12804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 755 ms 12748 KB Output is correct
2 Correct 810 ms 13080 KB Output is correct
3 Correct 660 ms 13048 KB Output is correct
4 Correct 899 ms 13004 KB Output is correct
5 Correct 783 ms 12988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 734 ms 15924 KB Output is correct
2 Correct 986 ms 15864 KB Output is correct
3 Execution timed out 1092 ms 15924 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 947 ms 15928 KB Output is correct
2 Correct 981 ms 16136 KB Output is correct
3 Correct 859 ms 15812 KB Output is correct
4 Execution timed out 1090 ms 15824 KB Time limit exceeded
5 Halted 0 ms 0 KB -