#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 = 5;
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;
double max_dist = 0;
vector<Point> towers(tower_num);
for (Point& t : towers) {
std::cin >> t.first >> t.second;
max_dist = std::max(max_dist, dist({0, 0}, t));
}
std::sort(towers.begin(), towers.end());
long long div_by = std::pow(10, PRECISION);
long long lo = 0;
long long hi = max_dist * div_by;
long long valid = -1;
while (lo <= hi) {
long long mid = (lo + hi) / 2;
double d = (double) mid / div_by;
double at = 0;
double d_sq = d * d;
for (Point& t : towers) {
double sqrt = std::sqrt(d_sq - 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 << (double) valid / div_by << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
308 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Incorrect |
2 ms |
368 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
316 KB |
Output is correct |
2 |
Incorrect |
4 ms |
440 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Incorrect |
4 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
424 KB |
Output is correct |
2 |
Incorrect |
4 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
65 ms |
2108 KB |
Output is correct |
2 |
Incorrect |
52 ms |
2504 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
2160 KB |
Output is correct |
2 |
Correct |
46 ms |
2208 KB |
Output is correct |
3 |
Incorrect |
58 ms |
2480 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
2292 KB |
Output is correct |
2 |
Incorrect |
56 ms |
2728 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
75 ms |
2504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
73 ms |
2452 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
261 ms |
8760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
391 ms |
8756 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
308 ms |
10316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
465 ms |
10332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
357 ms |
11892 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
531 ms |
11892 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
409 ms |
13452 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
612 ms |
13472 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
542 ms |
16592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
776 ms |
15964 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |