Submission #485117

# Submission time Handle Problem Language Result Execution time Memory
485117 2021-11-06T08:33:07 Z kakayoshi Balloons (CEOI11_bal) C++14
100 / 100
221 ms 1988 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef pair<ll, pair<ll, ll> > pii;
typedef vector <ll> vi;
#define forw(i,a,b) for (ll i=a;i<=(b);i++)
#define forb(i,a,b) for (ll i=a;i>=(b);i--)
#define fast {ios::sync_with_stdio(false); cin.tie(0); }
#define fi first
#define se second
#define pu push
#define puf push_front
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fr front
#define all(a) a.begin(),a.end()
const ll oo=1e18;
const ll mod=1e9+7;
const int base=31;
const int tx[5]={0,-1,0,1,0};
const int ty[5]={0,0,1,0,-1};
const ll maxN=1e5+5;
const ll maxM=1e6+5;
const ll block=700;
long double x,r;
ll n;
void solve()
{
    cin>>n;
    stack<pair<long double, long double> > p;
    forw(i,1,n)
    {
        cin>>x>>r;
        while (p.size())
        {
            long double  x1=p.top().fi;
            long double r1=p.top().se;
            r=min(r,((x1-x)*(x1-x))/(4*r1));
            if (r>=r1) p.pop();
            else break;
        }
        p.pu({x,r});
        cout<<fixed<<setprecision(3)<<r<<"\n";
    }
}
int main()
{
    fast;
    //freopen("bongbong.inp","r",stdin);
    //freopen("bongbong.out","w",stdout);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 22 ms 436 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 65 ms 972 KB 50000 numbers
2 Correct 51 ms 636 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 123 ms 1340 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 155 ms 1684 KB 115362 numbers
2 Correct 119 ms 996 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 171 ms 1860 KB 154271 numbers
2 Correct 195 ms 1492 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 221 ms 1988 KB 200000 numbers
2 Correct 199 ms 1536 KB 199945 numbers