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>
using namespace std;
#define InTheNameOfGod ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
using ll = long long;
const ll maxN = 2e5 + 5;
const ll MOD = 1e12 + 7;
const ll INF = 1e9 + 7;
double val(double x, double r) {
return x*x/4.0/r;
}
int main() {
InTheNameOfGod;
ll n;
cin >> n;
vector<pair<double, double> > v(n);
for(ll i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
}
vector<ll> ind;
ind.push_back(0);
vector<double> mo = {v[0].second};
for(ll i = 1; i < n; i++) {
double mini = val(v[i].first-v[ind[0]].first, mo[ind[0]]);
int l = 0, r = ind.size()-1;
while(l <= r) {
int mid = (l+r)/2;
if(val(v[i].first-v[ind[mid]].first, mo[ind[mid]]) < mini) {
mini = val(v[i].first-v[ind[mid]].first, mo[ind[mid]]);
l = mid+1;
}
else r = mid-1;
}
mini = min(mini, v[i].second);
mo.push_back(mini);
while(!ind.empty() && mo[ind.back()] < mini) ind.pop_back();
ind.push_back(i);
}
cout << fixed << setprecision(3);
for(ll i = 0; i < n; i++) cout << mo[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... |