이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ldb = long double;
using vi = vector<int>;
using vll = vector<ll>;
using vdb = vector<db>;
using vldb = vector<ldb>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
void solve()
{
int n; cin >> n;
vll x(n); vldb r(n);
for (int i = 0; i < n; i++)
cin >> x[i] >> r[i];
auto cmp = [&](int src, int i1, int i2)
{
ll dx1 = abs(x[src] - x[i1]);
ll dx2 = abs(x[src] - x[i2]);
double c1 = dx1 * dx1 * r[i2];
double c2 = dx2 * dx2 * r[i1];
return c1 < c2;
};
vi stk{0};
for (int i = 1; i < n; i++)
{
while (stk.size() > 1 && cmp(i, stk[stk.size() - 2], stk.back()))
stk.pop_back();
ll dx = abs(x[stk.back()] - x[i]);
r[i] = min(r[i], dx * dx / (r[stk.back()] * 4));
stk.pb(i);
}
for (int i = 0; i < n; i++)
cout << r[i] << " \n"[i==n-1];
}
int main()
{
ios_base::sync_with_stdio(false), cin.tie(0);
int t = 1;
// cin >> t;
while (t--) solve();
return 0;
}
# | 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... |