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;
int n;
long double getRad(long double d, long double r){
long double result = (long double)d*((long double)d/(4*r));
return result;
}
int main(){
cin >> n;
long double radius[n];
int position[n];
for(int i = 0; i < n; ++i) cin >> position[i] >> radius[i];
vector<pair<int, long double>> MyStack;
MyStack.reserve(n);
MyStack.push_back({position[0], radius[0]});
for(int i = 1; i < n; ++i){
int lastIdx = MyStack.size()-1;
radius[i] = min(radius[i], getRad(position[i]-MyStack[lastIdx].first, MyStack[lastIdx].second));
while(lastIdx>= 0 and radius[i] >= MyStack[lastIdx].second){
MyStack.pop_back();
lastIdx = MyStack.size()-1;
if(lastIdx>= 0) radius[i] = min(radius[i], getRad(position[i]-MyStack[lastIdx].first, MyStack[lastIdx].second));
}
MyStack.push_back({position[i], radius[i]});
}
for(int i = 0; i < n; ++i){
cout << radius[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... |