# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
732411 |
2023-04-29T03:56:12 Z |
uy842003 |
Mobile (BOI12_mobile) |
C++11 |
|
1000 ms |
51680 KB |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-4;
inline bool cmp_less(const double &a, const double &b) {
return a + eps < b;
}
inline bool cmp_equal(const double &a, const double &b) {
return abs(a - b) < eps;
}
inline bool cmp_less_equal(const double &a, const double &b) {
return cmp_less(a, b) || cmp_equal(a, b);
}
inline bool cmp_range(const pair<double, double> &p1, const pair<double, double> &p2) {
return cmp_less(p1.first, p2.first);
}
int main() {
int n;
double len;
cin >> n >> len;
vector<pair<double, double>> cor(n);
for (int i = 0; i < n; i++)
cin >> cor[i].first >> cor[i].second;
double l = 0, r = 1e10, m;
while (cmp_less(l, r)) {
m = (l + r) / 2;
vector<pair<double, double>> range, real_range;
for (int i = 0; i < n; i++) {
if (!cmp_less_equal(m, abs(cor[i].second))) {
double dx = sqrt(m * m - cor[i].second * cor[i].second);
range.push_back({cor[i].first - dx, cor[i].first + dx});
}
}
sort(range.begin(), range.end(), cmp_range);
pair<double, double> cur_range = {-1, -1};
if (range.size() > 0) cur_range = range[0];
for (int i = 0; i < range.size(); i++) {
if (cmp_less_equal(range[i].first, cur_range.second) && cmp_less(cur_range.second, range[i].second))
cur_range.second = range[i].second;
if (!cmp_less_equal(range[i].first, cur_range.second) || i + 1 == range.size()) {
real_range.push_back(cur_range);
cur_range = range[i];
}
}
bool iok = false;
for (int i = 0; i < real_range.size(); i++) {
if (cmp_less_equal(real_range[i].first, 0) && cmp_less_equal(len, real_range[i].second)) {
iok = true;
break;
}
}
if (iok)
r = m;
else
l = m + eps;
}
cout << setprecision(3) << fixed << r << endl;
return 0;
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:43:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for (int i = 0; i < range.size(); i++) {
| ~~^~~~~~~~~~~~~~
mobile.cpp:46:76: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | if (!cmp_less_equal(range[i].first, cur_range.second) || i + 1 == range.size()) {
| ~~~~~~^~~~~~~~~~~~~~~
mobile.cpp:52:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for (int i = 0; i < real_range.size(); i++) {
| ~~^~~~~~~~~~~~~~~~~~~
# |
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 |
296 KB |
Output is correct |
4 |
Correct |
1 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 |
300 KB |
Output is correct |
3 |
Correct |
2 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
468 KB |
Output is correct |
2 |
Correct |
8 ms |
468 KB |
Output is correct |
3 |
Correct |
5 ms |
340 KB |
Output is correct |
4 |
Correct |
9 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
628 KB |
Output is correct |
2 |
Correct |
20 ms |
580 KB |
Output is correct |
3 |
Correct |
21 ms |
584 KB |
Output is correct |
4 |
Correct |
13 ms |
580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
644 KB |
Output is correct |
2 |
Correct |
19 ms |
668 KB |
Output is correct |
3 |
Correct |
23 ms |
628 KB |
Output is correct |
4 |
Correct |
13 ms |
692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
636 KB |
Output is correct |
2 |
Correct |
20 ms |
692 KB |
Output is correct |
3 |
Correct |
25 ms |
624 KB |
Output is correct |
4 |
Correct |
12 ms |
664 KB |
Output is correct |
5 |
Correct |
13 ms |
580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
248 ms |
5512 KB |
Output is correct |
2 |
Correct |
425 ms |
5968 KB |
Output is correct |
3 |
Correct |
247 ms |
3012 KB |
Output is correct |
4 |
Correct |
198 ms |
4720 KB |
Output is correct |
5 |
Correct |
131 ms |
2908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
228 ms |
5616 KB |
Output is correct |
2 |
Correct |
204 ms |
4584 KB |
Output is correct |
3 |
Correct |
213 ms |
4908 KB |
Output is correct |
4 |
Correct |
216 ms |
4856 KB |
Output is correct |
5 |
Correct |
202 ms |
5072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
361 ms |
5868 KB |
Output is correct |
2 |
Correct |
447 ms |
6104 KB |
Output is correct |
3 |
Correct |
563 ms |
5020 KB |
Output is correct |
4 |
Correct |
222 ms |
5472 KB |
Output is correct |
5 |
Correct |
277 ms |
5180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
501 ms |
7116 KB |
Output is correct |
2 |
Correct |
544 ms |
6908 KB |
Output is correct |
3 |
Correct |
713 ms |
5472 KB |
Output is correct |
4 |
Correct |
199 ms |
5592 KB |
Output is correct |
5 |
Correct |
296 ms |
5568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
422 ms |
7108 KB |
Output is correct |
2 |
Correct |
539 ms |
5508 KB |
Output is correct |
3 |
Correct |
712 ms |
5500 KB |
Output is correct |
4 |
Correct |
213 ms |
5468 KB |
Output is correct |
5 |
Correct |
257 ms |
5492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
27856 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1020 ms |
28060 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1050 ms |
39208 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1044 ms |
39192 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1076 ms |
42352 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1016 ms |
42392 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1060 ms |
42724 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
45296 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1016 ms |
51680 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1065 ms |
19484 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |