이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, x;
stack<pair<int, double>> stk;
double r;
double ry(double rx, long long x, long long y) {
return ((x*x-2*x*y+y*y)/rx)/4.00;
}
double cmp(pair<int, double> e1, pair<int, double> e2, long long y) {
return (e2.second)*(1ll*e1.first*e1.first-2ll*e1.first*y+y*y) <= (e1.second)*(1ll*e2.first*e2.first-2ll*e2.first*y+y*y);
}
int main() {
cin.tie(0) -> sync_with_stdio(0);
cin >> n;
while(n--) {
cin >> x >> r;
while(stk.size() > 1) {
auto e2 = stk.top(); stk.pop(); auto e1 = stk.top();
if(cmp(e1, e2, x)) continue;
else {
stk.push(e2);
break;
}
}
if(stk.empty()) stk.emplace(x, r);
else stk.emplace(x, min(ry(stk.top().second, stk.top().first, x), r));
while(stk.size() > 1) {
auto e2 = stk.top(); stk.pop(); auto e1 = stk.top();
if(e1.second <= e2.second) {stk.pop(); stk.push(e2); continue;}
else { stk.push(e2); break; }
}
cout << stk.top().second << '\n';
}
}
# | 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... |