# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
998936 | hippo123 | Mobile (BOI12_mobile) | C++17 | 1076 ms | 33620 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 pr pair<int, int>
#define ll long long
#define pb push_back
#define f first
#define s second
vector<pr> d(1000001);
int n; double L;
bool comp(pr a, pr b){
if(a.f==b.f) return a.s*a.s<b.s*b.s;
return a.f<b.f;
}
bool check(double mid){
double xmin, xmax;
for (int i=0; i<n; i++){
double dx=mid*mid-d[i].s*d[i].s;
dx=pow(dx, 0.5);
double x1, x2;
x1=d[i].f-dx; x2=d[i].f+dx;
if(i==0) {
xmin=x1; xmax=x2;
}
else{
if(x1<=xmax) {
xmax=max(xmax, x2);
}
else{
break;
}
}
}
if(xmin<=0 && xmax>=L) return true;
else return false;
}
int main(){
cin>>n>>L;
for (int i=0; i<n; i++) {
cin>>d[i].f>>d[i].s;
}
sort(d.begin(), d.begin()+n, comp);
for (int i=0; i<n; i++) cout<<d[i].f<<" " <<d[i].s<<" :"<<endl;
double lft=0; double rht=L;
while (rht-lft>1e-5){
double mid=lft+(rht-lft)/2;
//cout<<" lft/rht/mid= "<<lft<<" "<<rht<<" "<<mid<<endl;
if(check(mid)) rht=mid;
else lft=mid;
}
cout << fixed <<setprecision(4);
cout<<lft<<endl;
}
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... |