#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;
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 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 |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
6 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
308 KB |
Output is correct |
4 |
Correct |
5 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
372 KB |
Output is correct |
2 |
Correct |
4 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
312 KB |
Output is correct |
4 |
Correct |
5 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
1464 KB |
Output is correct |
2 |
Correct |
53 ms |
1492 KB |
Output is correct |
3 |
Correct |
40 ms |
1756 KB |
Output is correct |
4 |
Correct |
63 ms |
2616 KB |
Output is correct |
5 |
Correct |
25 ms |
1464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
1516 KB |
Output is correct |
2 |
Correct |
46 ms |
1364 KB |
Output is correct |
3 |
Correct |
56 ms |
1492 KB |
Output is correct |
4 |
Correct |
80 ms |
2676 KB |
Output is correct |
5 |
Correct |
73 ms |
3040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
1620 KB |
Output is correct |
2 |
Correct |
56 ms |
1576 KB |
Output is correct |
3 |
Correct |
52 ms |
2500 KB |
Output is correct |
4 |
Correct |
94 ms |
3760 KB |
Output is correct |
5 |
Correct |
59 ms |
2696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
78 ms |
1852 KB |
Output is correct |
2 |
Correct |
71 ms |
3252 KB |
Output is correct |
3 |
Correct |
58 ms |
2892 KB |
Output is correct |
4 |
Correct |
93 ms |
3756 KB |
Output is correct |
5 |
Correct |
71 ms |
3108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
1748 KB |
Output is correct |
2 |
Correct |
67 ms |
3264 KB |
Output is correct |
3 |
Correct |
57 ms |
2892 KB |
Output is correct |
4 |
Correct |
98 ms |
3768 KB |
Output is correct |
5 |
Correct |
70 ms |
3116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
258 ms |
8124 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
371 ms |
8116 KB |
Output is correct |
2 |
Correct |
415 ms |
14776 KB |
Output is correct |
3 |
Correct |
295 ms |
13880 KB |
Output is correct |
4 |
Correct |
443 ms |
17452 KB |
Output is correct |
5 |
Correct |
400 ms |
15424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
308 ms |
9696 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
446 ms |
9684 KB |
Output is correct |
2 |
Correct |
512 ms |
17732 KB |
Output is correct |
3 |
Correct |
352 ms |
16464 KB |
Output is correct |
4 |
Correct |
554 ms |
21424 KB |
Output is correct |
5 |
Correct |
458 ms |
18660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
347 ms |
11248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
521 ms |
11252 KB |
Output is correct |
2 |
Correct |
565 ms |
20592 KB |
Output is correct |
3 |
Correct |
426 ms |
19660 KB |
Output is correct |
4 |
Correct |
655 ms |
24648 KB |
Output is correct |
5 |
Correct |
533 ms |
21652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
397 ms |
12816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
597 ms |
12824 KB |
Output is correct |
2 |
Correct |
631 ms |
23388 KB |
Output is correct |
3 |
Correct |
482 ms |
22284 KB |
Output is correct |
4 |
Correct |
770 ms |
28372 KB |
Output is correct |
5 |
Correct |
597 ms |
24324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
502 ms |
15956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
768 ms |
15956 KB |
Output is correct |
2 |
Correct |
814 ms |
29172 KB |
Output is correct |
3 |
Correct |
619 ms |
28236 KB |
Output is correct |
4 |
Correct |
915 ms |
35308 KB |
Output is correct |
5 |
Correct |
763 ms |
30676 KB |
Output is correct |