이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
int n;
long double radius(int d, long double r){
return (long double)(d*d)/(4*r);
}
int main(){
cin >> n;
vector<pair<int, long double>> MyStack;
//Mystack[i] = {position, radius}
vector<long double> answers(n);
vi position(n);
vi limit(n);
for(int i = 0; i < n; ++i) cin >> position[i] >> limit[i];
answers[0] = limit[0];
MyStack.push_back({position[0], (long double)limit[0]});
for(int i = 1; i < n; ++i){
int it = MyStack.size()-2;
while(it >= 0 and (radius(position[i]-MyStack[it].first, MyStack[it].second) < radius(position[i]-MyStack[it+1].first, MyStack[it+1].second)) and ((long double)limit[i] > radius(position[i]-MyStack[it+1].first, MyStack[it+1].second) ) ){
MyStack.pop_back();
it--;
}
long double rad = min((long double)limit[i], radius(position[i]-MyStack[MyStack.size()-1].first, MyStack[MyStack.size()-1].second) );
MyStack.push_back({position[i], rad});
answers[i] = rad;
}
cout << fixed << setprecision(3);
for (long double ans: answers) cout << ans << 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... |