이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define maxn 100005
long double delta = 0.000001;
#define fin std::cin
#define fout std::cout
std::vector <std::pair <long double, long double>> v;
bool check(long double lenght, long double l) {
long double left = -123, right = -123;
for(auto i: v) {
if(l*l - i.second * i.second < 0)
continue;
long double r = sqrtl(l*l - i.second * i.second);
if(left == -123 and right == -123) {
right = i.first + r;
left = i.first - r;
continue;
}
if(right >= i.first - r) {
right = std::max(right, i.first + r);
left = std::min(left, i.first - r);
}
}
if(left <= 0 and right >= lenght)
return true;
return false;
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
int n;
long double lenght;
fin >> n >> lenght;
v.resize(n);
for(int i = 0; i < n; i ++)
fin >> v[i].first >> v[i].second;
long double left = 0, right = 2e9, mid, ans = 0;
while(right - left >= delta) {
mid = (left + right) / 2;
if(check(lenght, mid) == true) {
ans = mid;
right = mid - delta;
}
else
left = mid + delta;
}
fout << ans << '\n';
return 0;
}
# | 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... |