This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
double calc(pair<double,double> a,double bx){
return (a.first-bx)*(a.first-bx)/(4*a.second);
}
int n;
int main()
{
cin >> n;
vector<double> answer(n);
stack<pair<double,double>> s;
for(int i = 0;i<n;i++){
double x,r;
cin >> x >> r;
double ans = r;
while(!s.empty()){
pair<double,double> cur = s.top();
ans = min(ans,calc(cur,x));
if(ans >= cur.second){
s.pop();
continue;
}
break;
}
s.push(make_pair(x,ans));
answer[i] = ans;
}
cout << fixed << setprecision(3);
for(int i = 0;i<n;i++){
cout << answer[i] << endl;
}
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... |