이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
const int N = 1e6+5;
int n, m;
pair<long double, long double> p[N];
stack<pair<int, pair<long double, long double>>> s;
long double dis(int i, long double x)
{
long double y = 0;
return hypot((x-p[i].f), (y-p[i].s));
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(int i=0; i<n; i++) cin >> p[i].f >> p[i].s;
for(int i=0; i<n; i++)
{
if(s.empty()) s.push({i, {0, m}});
else
{
auto t = s.top();
if(p[i].f == p[t.f].f || dis(t.f, t.s.s) < dis(i, t.s.s))
continue;
long double x;
while(!s.empty() && dis(s.top().f, s.top().s.f) >= dis(i, s.top().s.f)) x = s.top().s.f, s.pop();
if(s.empty())
{
s.push({i, {0, m}});
continue;
}
t = s.top();
if(dis(t.f, t.s.s) >= dis(i, t.s.s))
{
long double x1 = p[i].f, x2 = p[t.f].f;
long double y1 = p[i].s, y2 = p[t.f].s;
x = (x1*x1 - x2*x2 + y1*y1-y2*y2)/(2*x1-2*x2);
if(x <= t.s.f) continue;
s.pop();
t.s.s = x;
s.push(t);
}
s.push({i, {x, m}});
}
}
long double ans = 0;
while(!s.empty())
{
auto t = s.top();
s.pop();
ans = max(ans, max(dis(t.f, t.s.f), dis(t.f, t.s.s)));
}
cout << fixed << setprecision(7) << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |