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>
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-1], x));
double rate = 1 / (2*ans[i]);
ans[i] *= ans[i];
while (!mono.empty() && mono.back().second >= rate) {
sz--;
mono.pop_back();
}
sz++;
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... |