이 제출은 이전 버전의 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)*((long double) d/(4*r));
}
int main(){
cin >> n;
int lastIdx;
int position[n];
long double radius[n];
vector<pair<int, long double>> MyStack;
cin >> position[0] >> radius[0];
MyStack.push_back({position[0], radius[0]});
for(int i = 1; i < n; ++i){
cin >> position[i] >> radius[i];
while((MyStack.size() > 1)){
lastIdx = MyStack.size()-1;
long double LastRad = Radius(position[i] - MyStack[lastIdx].first, MyStack[lastIdx].second);
long double PrevRad = Radius(position[i] - MyStack[lastIdx-1].first, MyStack[lastIdx-1].second);
if (radius[i] < min(LastRad, PrevRad)) break;
if(LastRad > PrevRad) MyStack.pop_back();
else break;
}
lastIdx = MyStack.size()-1;
long double finalRad = Radius(position[i] - MyStack[lastIdx].first, MyStack[lastIdx].second);
radius[i] = min(radius[i], finalRad);
MyStack.push_back({position[i], radius[i]});
}
for(int i = 0; i < n; ++i) cout << fixed << 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... |