이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define speed \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
using namespace std;
bool no_conflict(double ri, double rj, ll xi, ll xj)
{
double lhs = 4 * ri * rj;
double rhs = (xi - xj) * (xi - xj);
return lhs > rhs;
}
double calc_r(ll xi, ll xj, double rj)
{
double numerator = (xi - xj) * (xi - xj);
double denominator = 4 * rj;
return numerator / double(denominator);
}
void solve(ll tc)
{
ll n;
cin >> n;
vector<ll> x(n), r(n);
vector<double> res(n);
for (ll i = 0; i < n; ++i)
{
cin >> x[i] >> r[i];
}
stack<pair<ll, double>> s;
for (ll i = 0; i < n; ++i)
{
if (s.empty())
res[i] = double(r[i]);
else
{
while (!s.empty() && double(r[i]) > s.top().second && no_conflict(r[i], s.top().second, x[i], s.top().first))
s.pop();
if (!s.empty())
res[i] = min(double(r[i]), calc_r(x[i], s.top().first, s.top().second));
else
res[i] = double(r[i]);
}
s.push({x[i], r[i]});
}
for (ll i = 0; i < n; ++i)
cout << fixed << setprecision(3) << res[i] << "\n";
}
int main()
{
speed;
ll t = 1;
// cin >> t;
for (ll i = 1; i <= t; i++)
solve(i);
}
# | 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... |