이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define cIO ios_base::sync_with_stdio(0);cin.tie(0)
#define fileIO(x) ifstream fin(string(x)+".in"); ofstream fout(string(x)+".out")
#define ll long long
#define ld long double
#define sz(x) (int) (x).size()
#define v vector
#define pb push_back
ll bal[200001][2];//[0]=x, [1]=r
ld ans[200001] = {};
int n;
ld get_rad(int b2, int b1)//b2 is the balloon we want to inflate, b1 is the balloon we want to intersect
{
ld rad = (ld)(bal[b2][0] - bal[b1][0]);
return rad * rad / (ld)ans[b1] / 4;
}
int main()
{
cin >> n;
for (int i = 0; i <= n-1; i++)
{
cin >> bal[i][0] >> bal[i][1];
}
stack<ll> stk;//stores the indices of the big bal we need to consider
ans[0] = (ld)bal[0][1];
stk.push(0);
for (int i = 1; i <= n - 1; i++)
{
ld next_rad = min((ld)bal[i][1], get_rad(i, stk.top()));//if this value is less than the radius of the top balloon, we can continue
while (!stk.empty()&&next_rad > ans[stk.top()])
{
stk.pop();
if (stk.empty()) break;
next_rad = min(next_rad, get_rad(i, stk.top()));
}
stk.push(i);
ans[i] = next_rad;
}
cout << fixed << setprecision(4);
for (int i = 0; i <= n - 1; i++) cout << ans[i] << "\n";
}
# | 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... |