#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define mod 1000000007
#define inf 1e18
#define endl "\n"
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, init, n) for (int i = init; i < (int)n; i++)
#define rev(i, n, init) for (int i = (int)n; i >= init; i--)
#define V vector<int>
#define VV vector<V>
#define Vll vector<ll>
#define VVll vector<Vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define Vpii vector<pii>
#define VVpii vector<Vpii>
#define Vpll vector<pll>
#define VVpll vector<Vpll>
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // find_by_order, order_of_key
#ifndef Anurag203
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(double t) {cerr << t;}
template <class T, class vv> void _print(pair <T, vv> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class vv> void _print(map <T, vv> v);
template <class T> void _print(multiset <T> v);
template <class T> void _print(ordered_set <T> v);
template <class T, class vv> void _print(pair <T, vv> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class vv> void _print(map <T, vv> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(ordered_set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
/*----------------------------------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll powe(ll x,ll y, ll p=mod){ll res = 1; x = x % p;while (y > 0){ if (y & 1) res = (res * x) % p;y = y >> 1; x = (x * x) % p;} return res;}
bool revsort(ll a, ll b) {return a > b;}
ll inverse_modulo(ll a, ll p = mod) {return powe(a, p - 2, p);}
Vll fact; void fill_fact(ll p = mod) {fact.resize(200005, 1); rep(i, 1, 200005) { fact[i] = (fact[i - 1] * i) % p; }}
ll C(ll n,ll r,ll p=mod) {return ((fact[n]*inverse_modulo(fact[n-r]))%mod*inverse_modulo(fact[r]))%mod;}
void google(int t) {cout << "Case #" << t << ": ";}
Vll spf; void sieve(ll n = 200005) {spf.resize(n + 1, 1); ll i, j; for (ll i = 2; i <= n; i++) {if (spf[i] == 1) {spf[i] = i; for (j = i * i; j <= n; j += i){if (spf[j] == 1) spf[j] = i;}}}}
bool is_prime(ll x) {return (spf[x] == x);}
Vpll prime_factors(ll x) {Vpll ans; while (x != 1) {ll a = spf[x], cnt = 0; while (x % a == 0) x /= a, cnt++; ans.pb({a, cnt});}return ans;}
/*----------------------------------------------------------------------------------------------------------------------------------------------------*/
double n, l;
bool check(double mid, vector<pair<double, double>> &a)
{
vector<pair<double, int>> v;
for (auto e : a)
{
if (mid < e.ss) continue;
double x = (double)sqrt((mid * mid) - (e.ss * e.ss));
v.pb({max(0.0, e.ff - x), -1});
v.pb({min(l, e.ff + x), 1});
}
sort(all(v));
int m = v.size();
if (v[0].ff != 0.0 || v[m - 1].ff != l) return false;
int cnt = 0;
rep(i, 0, m - 1)
{
cnt -= v[i].ss;
if (cnt == 0) return false;
}
return true;
}
void solve()
{
cin >> n >> l;
vector<pair<double, double>> a(n);
rep(i, 0, n) cin >> a[i].first >> a[i].second;
double l = 0, r = 1e10, ans;
rep(i, 0, 60)
{
double mid = (l + r) / 2;
if (check(mid, a))
{
ans = mid;
r = mid;
}
else l = mid;
}
cout << fixed << setprecision(6) << ans << endl;
}
int main() {
#ifndef Anurag203
freopen("Error.txt", "w", stderr);
#endif
fastio();
// freopen("output.in", "r", stdin);
// freopen("output.out", "w", stdout);
int tt = 1;
// cin>>tt;
rep(ii, 1, tt + 1)
{
// google(ii);
solve();
}
return 0;
}
Compilation message
mobile.cpp: In function 'void sieve(long long int)':
mobile.cpp:66:62: warning: unused variable 'i' [-Wunused-variable]
66 | Vll spf; void sieve(ll n = 200005) {spf.resize(n + 1, 1); ll i, j; for (ll i = 2; i <= n; i++) {if (spf[i] == 1) {spf[i] = i; for (j = i * i; j <= n; j += i){if (spf[j] == 1) spf[j] = i;}}}}
| ^
mobile.cpp: In function 'int main()':
mobile.cpp:113:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
113 | freopen("Error.txt", "w", stderr);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
724 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
26 ms |
1156 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
1176 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
434 ms |
8192 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
427 ms |
10120 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
599 ms |
9212 KB |
Output is correct |
2 |
Correct |
528 ms |
8596 KB |
Output is correct |
3 |
Correct |
390 ms |
9052 KB |
Output is correct |
4 |
Incorrect |
625 ms |
9256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
625 ms |
10184 KB |
Output is correct |
2 |
Correct |
679 ms |
9268 KB |
Output is correct |
3 |
Correct |
557 ms |
10028 KB |
Output is correct |
4 |
Incorrect |
614 ms |
9856 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
563 ms |
9312 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1065 ms |
40348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1059 ms |
40440 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1041 ms |
60872 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1071 ms |
59064 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1022 ms |
61528 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1018 ms |
62132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1047 ms |
62880 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1060 ms |
62772 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1029 ms |
65684 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1050 ms |
66328 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |