This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifndef Local
#pragma GCC optimize("O3,unroll-loops")
#endif
#include <bits/stdc++.h>
#define int long long
#define pb push_back
using namespace std;
const int lim=2e5+1;
int mod=1e9+7;
using pii=pair<int,int>;
void solve(){
int n;
cin>>n;
double x[n],r[n];
for(int i=0;i<n;i++){
cin>>x[i]>>r[i];
}
cout<<fixed<<setprecision(3);
stack<pair<double,double>>s;
for(int i=0;i<n;i++){
double cur=r[i];
while(s.size()){
double dist=(x[i]-s.top().second);
cur=min(dist*dist/(4*s.top().first),r[i]);
if(s.top().first<=cur)s.pop();
else break;
}
cout<<cur<<"\n";
s.push({cur,x[i]});
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
#ifdef Local
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#else
//freopen("dishes.in","r",stdin);
//freopen("dishes.out","w",stdout);
#endif
int t=1;
//cin>>t;
while (t--)
{
solve();
}
}
# | 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... |