Submission #485140

# Submission time Handle Problem Language Result Execution time Memory
485140 2021-11-06T10:23:07 Z hammer23 Balloons (CEOI11_bal) C++14
100 / 100
163 ms 8348 KB
#include <bits/stdc++.h>
using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
typedef pair<int,int> pii;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ll long long
#define numBit(x) __builtin_popcount(x)
#define lb lower_bound
#define ub upper_bound
#define ar array
#define endl '\n'
#define fi first
#define se second

const int inf = 1e9+1;
const int maxN = 2e5 + 1;
const int MOD = 1e9 + 7;

using namespace std;
 ll powmod(ll a, ll b, ll p){
    a %= p;
    if (a == 0) return 0;
    ll product = 1;
    while(b > 0){
        if (b&1){
            product *= a;
            product %= p;
            --b;
        }
        a *= a;
        a %= p;
        b /= 2;
    }
    return product;
}
 ll inv(ll a, ll p){
    return powmod(a, p-2, p);
}

 ll DIVMOD(ll a, ll b, ll p){
    // A*(B^(MOD-2))%MOD
    return a*inv(b,p)%p;
}
void file(const string FILE = "bongbong") {
    //freopen((FILE + ".INP").c_str(), "r", stdin);
    //freopen((FILE + ".OUT").c_str(), "w", stdout);
}

int n;
long double x[maxN];
long double r[maxN],pck[maxN];
void solve(){
    stack<int> st;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>r[i];
    }

    for(int i=0;i<n;i++){
        while(!st.empty()){
            int j=st.top();
            r[i]=min(r[i],(x[i]-x[j])*(x[i]-x[j])/(4.0*r[j]));
            if(r[i]>=r[j]) st.pop();
            else break;
        }
        st.push(i);
        //cout<<ans<<setprecision(3)<<endl;
        printf("%.3Lf \n", r[i]);
    }
}

int main()
{
    //file();
    fastIO;
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 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 17 ms 1092 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 49 ms 2300 KB 50000 numbers
2 Correct 40 ms 2180 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 86 ms 4400 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 100 ms 5100 KB 115362 numbers
2 Correct 92 ms 4928 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 139 ms 6592 KB 154271 numbers
2 Correct 154 ms 8132 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 163 ms 8348 KB 200000 numbers
2 Correct 152 ms 7876 KB 199945 numbers