# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1083688 |
2024-09-03T20:26:32 Z |
vjudge1 |
Mobile (BOI12_mobile) |
C++17 |
|
1000 ms |
35152 KB |
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
// Function to check if all points on the highway [0, L] can be covered with distance R
bool canCoverAllPoints(const vector<pair<double, double>>& stations, double R, double L) {
double currentCoverage = 0.0;
for (const auto& station : stations) {
double xi = station.first;
double yi = station.second;
if (yi > R) continue; // This base station cannot help at this R
double reach = sqrt(R * R - yi * yi);
double startCoverage = max(0.0, xi - reach);
double endCoverage = xi + reach;
// If this base station can extend the coverage
if (startCoverage <= currentCoverage) {
currentCoverage = max(currentCoverage, endCoverage);
}
if (currentCoverage >= L) return true;
}
return currentCoverage >= L;
}
int main() {
int N;
double L;
cin >> N >> L;
vector<pair<double, double>> stations(N);
for (int i = 0; i < N; ++i) {
double xi, yi;
cin >> xi >> yi;
stations[i] = {xi, yi};
}
// Binary search for the smallest possible R
double low = 0.0;
double high = 1e9;
double epsilon = 1e-7; // Tighten the precision for better performance
while (high - low > epsilon) {
double mid = (low + high) / 2.0;
if (canCoverAllPoints(stations, mid, L)) {
high = mid; // Try smaller radius
} else {
low = mid; // Increase radius
}
}
cout << fixed << setprecision(6) << high << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
4 ms |
452 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
4 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
348 KB |
Output is correct |
2 |
Correct |
4 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
4 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
4 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
2388 KB |
Output is correct |
2 |
Correct |
52 ms |
2636 KB |
Output is correct |
3 |
Correct |
31 ms |
1884 KB |
Output is correct |
4 |
Correct |
67 ms |
2768 KB |
Output is correct |
5 |
Correct |
25 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
2396 KB |
Output is correct |
2 |
Correct |
56 ms |
2140 KB |
Output is correct |
3 |
Correct |
63 ms |
2592 KB |
Output is correct |
4 |
Correct |
70 ms |
2644 KB |
Output is correct |
5 |
Correct |
84 ms |
3188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
2392 KB |
Output is correct |
2 |
Correct |
52 ms |
2640 KB |
Output is correct |
3 |
Correct |
47 ms |
2644 KB |
Output is correct |
4 |
Correct |
104 ms |
3884 KB |
Output is correct |
5 |
Correct |
59 ms |
2744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
3372 KB |
Output is correct |
2 |
Correct |
65 ms |
3152 KB |
Output is correct |
3 |
Correct |
54 ms |
3016 KB |
Output is correct |
4 |
Correct |
108 ms |
3920 KB |
Output is correct |
5 |
Correct |
77 ms |
3156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
3412 KB |
Output is correct |
2 |
Correct |
67 ms |
3152 KB |
Output is correct |
3 |
Correct |
54 ms |
3008 KB |
Output is correct |
4 |
Correct |
104 ms |
3920 KB |
Output is correct |
5 |
Correct |
79 ms |
3264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
290 ms |
12372 KB |
Output is correct |
2 |
Correct |
360 ms |
15912 KB |
Output is correct |
3 |
Correct |
311 ms |
15444 KB |
Output is correct |
4 |
Correct |
516 ms |
18000 KB |
Output is correct |
5 |
Correct |
416 ms |
14912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
377 ms |
16464 KB |
Output is correct |
2 |
Correct |
382 ms |
14676 KB |
Output is correct |
3 |
Correct |
280 ms |
13864 KB |
Output is correct |
4 |
Correct |
508 ms |
17576 KB |
Output is correct |
5 |
Correct |
481 ms |
15444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
347 ms |
14928 KB |
Output is correct |
2 |
Correct |
421 ms |
19012 KB |
Output is correct |
3 |
Correct |
369 ms |
18256 KB |
Output is correct |
4 |
Correct |
630 ms |
21464 KB |
Output is correct |
5 |
Correct |
535 ms |
17740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
443 ms |
19656 KB |
Output is correct |
2 |
Correct |
487 ms |
17496 KB |
Output is correct |
3 |
Correct |
341 ms |
16464 KB |
Output is correct |
4 |
Correct |
628 ms |
21448 KB |
Output is correct |
5 |
Correct |
518 ms |
18384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
408 ms |
17248 KB |
Output is correct |
2 |
Correct |
479 ms |
22100 KB |
Output is correct |
3 |
Correct |
455 ms |
21316 KB |
Output is correct |
4 |
Correct |
721 ms |
25168 KB |
Output is correct |
5 |
Correct |
564 ms |
20404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
498 ms |
22756 KB |
Output is correct |
2 |
Correct |
516 ms |
20692 KB |
Output is correct |
3 |
Correct |
419 ms |
19540 KB |
Output is correct |
4 |
Correct |
735 ms |
24656 KB |
Output is correct |
5 |
Correct |
607 ms |
21472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
467 ms |
19976 KB |
Output is correct |
2 |
Correct |
561 ms |
25172 KB |
Output is correct |
3 |
Correct |
500 ms |
24404 KB |
Output is correct |
4 |
Correct |
866 ms |
28496 KB |
Output is correct |
5 |
Correct |
708 ms |
23936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
661 ms |
26192 KB |
Output is correct |
2 |
Correct |
592 ms |
23636 KB |
Output is correct |
3 |
Correct |
450 ms |
22352 KB |
Output is correct |
4 |
Correct |
838 ms |
28180 KB |
Output is correct |
5 |
Correct |
713 ms |
24404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
591 ms |
24768 KB |
Output is correct |
2 |
Correct |
659 ms |
31572 KB |
Output is correct |
3 |
Correct |
677 ms |
30420 KB |
Output is correct |
4 |
Execution timed out |
1041 ms |
35004 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
735 ms |
32568 KB |
Output is correct |
2 |
Correct |
754 ms |
29272 KB |
Output is correct |
3 |
Correct |
592 ms |
28356 KB |
Output is correct |
4 |
Execution timed out |
1056 ms |
35152 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |