이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<long double, long double> ll;
const int MAX_N = 200000;
int n;
long double x[MAX_N + 1], r[MAX_N + 1];
long double r_al[MAX_N + 1];
stack<ll> s;
long double expected_val(long double x1, long double r1, long double x2)
{
return (x1 - x2) * (x1 - x2) / (4.0 * r1);
}
int main()
{
//freopen("test.in","r",stdin);
//freopen("test.out","w",stdout);
cin>>n;
for(int i = 0; i < n; i++){
cin>>x[i]>>r[i];
}
for(int i = 0; i < n; i++){
long double tmp = r[i];
while(!s.empty()){
tmp = min(tmp, expected_val(s.top().first, s.top().second, x[i]));
if(tmp >= s.top().second){
s.pop();
continue;
}
else break;
}
if(!s.empty()) tmp = min(tmp, expected_val(s.top().first, s.top().second, x[i]));
s.push(ll(x[i], tmp));
printf("%.3Lf\n", tmp);
}
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... |