# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
557508 |
2022-05-05T12:06:04 Z |
aryan12 |
Mobile (BOI12_mobile) |
C++17 |
|
1000 ms |
31756 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e6 + 5;
vector<pair<long double, long double> > coordinates(N);
int n, l;
bool Check(long double value)
{
// sqrt[(c[i].x - x) ^ 2 + (c[i].y - 0) ^ 2] = value
// (c[i].x - x) ^ 2 + c[i].y ^ 2 = value * value
// c[i].x - x = sqrt[(value * value) - c[i].y ^ 2]
// - x = sqrt[(value * value) - c[i].y ^ 2] - c[i].x
// x = c[i].x - sqrt[(value * value) - c[i].y ^ 2]
long double maxLeft = 0;
for(int i = 1; i <= n; i++)
{
long double cur_left = 0.0, cur_right = 0.0;
cur_left = coordinates[i].first - sqrt((value * value) - (coordinates[i].second * coordinates[i].second));
cur_right = coordinates[i].first + sqrt((value * value) - (coordinates[i].second * coordinates[i].second));
if(cur_left <= maxLeft)
{
maxLeft = max(maxLeft, cur_right);
}
}
return (maxLeft >= l);
}
void Solve()
{
cin >> n >> l;
for(int i = 1; i <= n; i++)
{
cin >> coordinates[i].first >> coordinates[i].second;
}
long double left = 0, right = 1e9;
long double ans = right + 1;
while(right - left >= 0.0001)
{
// cout << "left = " << left << ", right = " << right << "\n";
long double mid = (left + right) / 2;
if(Check(mid))
{
right = mid;
ans = mid;
}
else
{
left = mid;
}
}
cout << fixed << setprecision(8) << ans << "\n";
}
int32_t main()
{
auto begin = std::chrono::high_resolution_clock::now();
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
for(int i = 1; i <= t; i++)
{
//cout << "Case #" << i << ": ";
Solve();
}
auto end = std::chrono::high_resolution_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
31568 KB |
Output is correct |
2 |
Correct |
28 ms |
31532 KB |
Output is correct |
3 |
Correct |
28 ms |
31628 KB |
Output is correct |
4 |
Correct |
28 ms |
31564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
31616 KB |
Output is correct |
2 |
Correct |
26 ms |
31548 KB |
Output is correct |
3 |
Correct |
26 ms |
31584 KB |
Output is correct |
4 |
Correct |
27 ms |
31580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
31636 KB |
Output is correct |
2 |
Correct |
31 ms |
31592 KB |
Output is correct |
3 |
Correct |
31 ms |
31536 KB |
Output is correct |
4 |
Correct |
28 ms |
31564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
31648 KB |
Output is correct |
2 |
Correct |
31 ms |
31572 KB |
Output is correct |
3 |
Correct |
31 ms |
31564 KB |
Output is correct |
4 |
Correct |
37 ms |
31540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
31636 KB |
Output is correct |
2 |
Correct |
34 ms |
31720 KB |
Output is correct |
3 |
Correct |
30 ms |
31540 KB |
Output is correct |
4 |
Correct |
34 ms |
31616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
31588 KB |
Output is correct |
2 |
Correct |
29 ms |
31592 KB |
Output is correct |
3 |
Correct |
29 ms |
31632 KB |
Output is correct |
4 |
Correct |
38 ms |
31632 KB |
Output is correct |
5 |
Correct |
31 ms |
31564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
155 ms |
31640 KB |
Output is correct |
2 |
Correct |
83 ms |
31640 KB |
Output is correct |
3 |
Correct |
81 ms |
31636 KB |
Output is correct |
4 |
Correct |
174 ms |
31640 KB |
Output is correct |
5 |
Correct |
102 ms |
31636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
161 ms |
31644 KB |
Output is correct |
2 |
Correct |
142 ms |
31636 KB |
Output is correct |
3 |
Correct |
171 ms |
31552 KB |
Output is correct |
4 |
Correct |
192 ms |
31588 KB |
Output is correct |
5 |
Correct |
202 ms |
31756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
80 ms |
31612 KB |
Output is correct |
2 |
Correct |
83 ms |
31640 KB |
Output is correct |
3 |
Correct |
116 ms |
31640 KB |
Output is correct |
4 |
Correct |
264 ms |
31636 KB |
Output is correct |
5 |
Correct |
161 ms |
31652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
106 ms |
31636 KB |
Output is correct |
2 |
Correct |
105 ms |
31636 KB |
Output is correct |
3 |
Correct |
118 ms |
31640 KB |
Output is correct |
4 |
Correct |
247 ms |
31636 KB |
Output is correct |
5 |
Correct |
222 ms |
31644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
98 ms |
31632 KB |
Output is correct |
2 |
Correct |
95 ms |
31656 KB |
Output is correct |
3 |
Correct |
123 ms |
31636 KB |
Output is correct |
4 |
Correct |
284 ms |
31640 KB |
Output is correct |
5 |
Correct |
232 ms |
31640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
357 ms |
31640 KB |
Output is correct |
2 |
Correct |
433 ms |
31640 KB |
Output is correct |
3 |
Correct |
398 ms |
31632 KB |
Output is correct |
4 |
Execution timed out |
1096 ms |
31628 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
414 ms |
31640 KB |
Output is correct |
2 |
Correct |
850 ms |
31640 KB |
Output is correct |
3 |
Correct |
487 ms |
31632 KB |
Output is correct |
4 |
Execution timed out |
1096 ms |
31624 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
403 ms |
31636 KB |
Output is correct |
2 |
Correct |
504 ms |
31608 KB |
Output is correct |
3 |
Correct |
488 ms |
31640 KB |
Output is correct |
4 |
Execution timed out |
1083 ms |
31564 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
519 ms |
31696 KB |
Output is correct |
2 |
Correct |
934 ms |
31640 KB |
Output is correct |
3 |
Correct |
649 ms |
31640 KB |
Output is correct |
4 |
Execution timed out |
1088 ms |
31564 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
481 ms |
31736 KB |
Output is correct |
2 |
Correct |
547 ms |
31636 KB |
Output is correct |
3 |
Correct |
562 ms |
31636 KB |
Output is correct |
4 |
Execution timed out |
1091 ms |
31528 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
556 ms |
31640 KB |
Output is correct |
2 |
Execution timed out |
1093 ms |
31604 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
564 ms |
31640 KB |
Output is correct |
2 |
Correct |
595 ms |
31632 KB |
Output is correct |
3 |
Correct |
632 ms |
31640 KB |
Output is correct |
4 |
Execution timed out |
1072 ms |
31564 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
608 ms |
31640 KB |
Output is correct |
2 |
Execution timed out |
1091 ms |
31572 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
723 ms |
31636 KB |
Output is correct |
2 |
Correct |
771 ms |
31692 KB |
Output is correct |
3 |
Correct |
783 ms |
31572 KB |
Output is correct |
4 |
Execution timed out |
1079 ms |
31560 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
767 ms |
31640 KB |
Output is correct |
2 |
Execution timed out |
1051 ms |
31564 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |