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>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define TASK "mincut"
#define ll long long
#define MAXN 1000006
#define pii pair<long long,long long>
#define pdd pair<double, double>
#define ppi pair<ll,pii>
#define ff first
#define ss second
#define pb push_back
#define oo 1e18
using namespace std;
const ll MOD=1e9+7;
bool minimize(ll &a,ll b)
{
if (a>b)
{
a=b;
return true;
}
return false;
}
bool maximize (ll &a,ll b)
{
if (a<b)
{
a=b;
return true;
}
return false;
}
ll n;
void nhap()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
}
double calc(pdd x,double y)
{
return ((x.ff-y)*(x.ff-y))/(4*1.0*x.ss);
}
void solve()
{
vector<double> ans;
ans.resize(n+5);
stack<pdd> check;
FOR(i,1,n)
{
double x,r;
cin >> x >> r;
double max_r=r;
while (!check.empty())
{
pdd last=check.top();
double last_r=calc(last,x);
max_r=min(max_r,last_r);
if (max_r>=last.ss)
{
check.pop();
continue;
}
else break;
}
check.push({x,max_r});
ans[i]=max_r;
}
FOR(i,1,n) cout << fixed << setprecision(3) << ans[i] << '\n';
}
int main()
{
nhap();
solve();
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... |