Submission #868379

# Submission time Handle Problem Language Result Execution time Memory
868379 2023-10-31T09:08:28 Z noyancanturk Balloons (CEOI11_bal) C++17
100 / 100
159 ms 8684 KB
#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),cur);
            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
1 Correct 0 ms 348 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 15 ms 860 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 48 ms 1620 KB 50000 numbers
2 Correct 41 ms 2504 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 77 ms 2804 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 89 ms 3260 KB 115362 numbers
2 Correct 88 ms 5204 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 118 ms 4124 KB 154271 numbers
2 Correct 147 ms 8684 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 159 ms 5116 KB 200000 numbers
2 Correct 141 ms 8528 KB 199945 numbers