Submission #1026872

# Submission time Handle Problem Language Result Execution time Memory
1026872 2024-07-18T12:35:57 Z peyman_sf Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 18616 KB
#include <iostream>
#include <fstream>
#include <iomanip>
#include <stack>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>


#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fileTesting ifstream fileIn("input.txt"); cin.rdbuf(fileIn.rdbuf()); ofstream fileOut("output.txt"); cout.rdbuf(fileOut.rdbuf());
#define endl '\n'
#define print(x) for (auto i : x) cout << i << ' '; cout << endl
#define nloop(a, n) for (ll i = a; i < n; i++)
#define debug(x) cerr << #x << " is " << x << endl
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

using namespace std;
typedef long long ll;
typedef double ld;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;

const ll maxN = 1e9;
const ll mod = 1e9 + 7;

ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b);}
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ld Sqrt(ld x) {
    ld l = 0, r = x;
    for (int t = 100; t--; ) {
        ld mid = (l + r) / 2;
        if (mid*mid <= x)
            l = mid;
        else
            r = mid;
    }
    return l;
}

ld n, len;
vector< pair<ld, ld> > points;

ld check(ld r) {
    ld cl = 0, cr = 0;
    for (auto &p : points)
    {
        ld d = Sqrt(r*r - p.second*p.second);
        if (p.first - d > cr)
            return 0;

        else {
            cl = min(cl, p.first - d);
            cr = max(cr, p.first + d);
        }
    }

    if (cl <= 0 && cr >= len)
        return 1;

    return 0;
}

void solution() {
    cin >> n >> len;

    for (ll i = 0; i < n; i++) {
        ld x, y;
        cin >> x >> y;
        points.push_back(make_pair(x, y));
    }

    ld l = 0, r = len + 1, m;
    for (ll i = 0; i < 100; i++) {
        m = (l + r) / 2;
        if (check(m))
            r = m;
        
        else
            l = m;
    }

    cout << fixed << setprecision(6) << r << endl;
}

int main() {
    FastIO
    ll t = 1;
    // cin >> t;
    while (t--) {
        solution();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 185 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 170 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 152 ms 648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 2516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 2516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1037 ms 2508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 714 ms 2520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1030 ms 2408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1012 ms 8636 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1016 ms 8640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 17692 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 17332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 18516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 17792 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1045 ms 17844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 18172 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1037 ms 17120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 18616 KB Time limit exceeded
2 Halted 0 ms 0 KB -