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 <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
using std::cout;
using std::endl;
using std::vector;
using Point = std::pair<long long, long long>;
constexpr int PRECISION = 4;
double dist(const Point& p1, const Point& p2) {
long long dx = p1.first - p2.first;
long long dy = p1.second - p2.second;
return std::sqrt(dx * dx + dy * dy);
}
/**
* https://oj.uz/problem/view/BOI12_mobile
* 2 10
* 0 0
* 11 1 should output something close to 5.545455
*/
int main() {
int tower_num;
int road_len;
std::cin >> tower_num >> road_len;
vector<Point> towers(tower_num);
for (Point& t : towers) {
std::cin >> t.first >> t.second;
}
std::sort(towers.begin(), towers.end());
long long div_by = std::pow(10, PRECISION);
long long lo = 0;
long long hi = INT64_MAX / 2;
long long valid = -1;
while (lo <= hi) {
long long mid = (lo + hi) / 2;
double power = (double) mid / div_by;
double at = 0;
for (Point& t : towers) {
double sqrt = std::sqrt(power * power - t.second * t.second);
double start = -sqrt + t.first;
double end = sqrt + t.first;
if (start <= at) {
at = std::max(at, end);
}
}
if (at >= road_len) {
valid = mid;
hi = mid - 1;
} else {
lo = mid + 1;
}
}
cout << std::fixed << std::setprecision(PRECISION)
<< (double) valid / div_by << endl;
}
# | 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... |