#include <bits/stdc++.h>
#define MAX (int)(1e6 + 5)
#define esq(x) (x<<1)
#define dir(x) ((x<<1)|1)
#define bug(x) cout << #x << " - " << x << endl
using namespace std;
double n, l, a[MAX], b[MAX];
vector<pair<double, double> > resp;
pair<double, double> last, now;
double dist(pair<double, double> a, pair<double, double> b)
{
return (a.first-b.first)*(a.first-b.first) + (b.second-a.second)*(b.second-a.second);
}
int pode(pair<double, double> last, pair<double, double> now, double pos)
{
return (dist(last, {pos, 0}) <= dist(now, {pos, 0}));
}
double bb(pair<double, double> last, pair<double, double> now)
{
int k = 40;
double mid, ini = last.first, fim = now.first;
while (k--)
{
mid = (ini+fim)/2;
if (pode(last, now, mid)) ini = mid;
else fim = mid;
}
return mid;
}
int main()
{
cin >> n >> l;
cin >> a[0] >> b[0];
if (n == 1)
{
if (dist({0, 0}, {a[0], b[0]}) > dist({l, l}, {a[0], b[0]})) cout << 0 << endl;
else cout << l << endl;
return 0;
}
last = {a[0], b[0]};
for (int i = 1; i < n; i++)
{
cin >> a[i] >> b[i];
now = {a[i], b[i]};
double tmp = bb(last, now);
resp.push_back({min(dist(last, {tmp, 0}), dist(now, {tmp, 0})), tmp});
// if (dist(last, {tmp, 0}) > dist(now, {tmp, 0})) last = now;
last = now;
}
sort(resp.begin(), resp.end(), greater<pair<double, double> >());
cout << fixed << setprecision(6) << resp[0].second << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
99 ms |
3528 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
118 ms |
3476 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
93 ms |
3492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
151 ms |
3544 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
167 ms |
3568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
550 ms |
16028 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
753 ms |
16276 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
666 ms |
25036 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
878 ms |
25040 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
746 ms |
24956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1064 ms |
25096 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
872 ms |
25412 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1088 ms |
25616 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1052 ms |
31936 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
25856 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |