# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
989981 | maithehung123 | Mobile (BOI12_mobile) | C++14 | 902 ms | 35436 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define BIT(i) (1LL << (i))
#define GBIT(mask,i) (((mask) >> (i)) & 1)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define sz(v) ((int)v.size())
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FOD(i,a,b) for(int i = a; i >= b; --i)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 2e9 + 7;
const long long infll = 1e18 + 7;
template<class T1,class T2> bool maximize(T1 &a,T2 b) {
if(a < b) {
a = b;
return 1;
}
return 0;
}
template<class T1,class T2> bool minimize(T1 &a,T2 b) {
if(a > b) {
a = b;
return 1;
}
return 0;
}
#define MAX 1000005
int n;
int L;
pll a[MAX];
bool check(long double x) {
long double cur = 0.0;
FOR(i,1,n) {
long double delta = sqrt(x * x - 1.0 * a[i].se * a[i].se);
long double left = a[i].fi - delta,right = a[i].fi + delta;
if(left <= cur) maximize(cur,right);
}
return cur >= L;
}
void process() {
cin >> n >> L;
FOR(i,1,n) cin >> a[i].fi >> a[i].se;
long double l = 0,r = 1e9 + 7,mid,res;
while(r - l >= 1e-5) {
mid = (l + r) / 2;
if(check(mid)) r = mid,res = mid;
else l = mid;
}
cout << fixed << setprecision(6) << res;
}
int main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#define TASK ""
if(fopen(TASK".inp","r")) {
freopen(TASK".inp","r",stdin);
freopen(TASK".out","w",stdout);
}
if(fopen("main.inp","r")) {
freopen("main.inp","r",stdin);
freopen("main.out","w",stdout);
}
srand(time(0));
process();
cerr << "\n" << (double)clock() / CLOCKS_PER_SEC * 1000 << "ms";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |