이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
template<class T> bool ckmin(T& a, T b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
typedef long long ll;
const char nl = '\n';
using namespace std;
int main()
{
int n; cin >> n;
vector<double> ans(n);
deque<pair<int, double>> mono;
int sz = 0;
auto eval = [&](pair<int, double> a, int b){ return a.second * (b - a.first); };
for (int i = 0; i < n; i++){
int x; double r;
cin >> x >> r;
while (sz >= 2 && eval(mono[sz-1], x) > eval(mono[sz-2], x)){
sz--;
mono.pop_back();
}
ans[i] = sqrt(r);
if (!mono.empty()) ckmin(ans[i], eval(mono[sz], x));
double rate = 0.5 * (1 / ans[i]);
ans[i] *= ans[i];
while (!mono.empty() && mono.back().second >= rate) mono.pop_back();
mono.push_back({x, rate});
}
cout << fixed << setprecision(10);
for (int i = 0; i < n; i++) cout << ans[i] << nl;
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... |