Submission #1117785

#TimeUsernameProblemLanguageResultExecution timeMemory
1117785IcelastBalloons (CEOI11_bal)C++17
100 / 100
136 ms14932 KiB
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn = 2*1e5+5, INF = 4e18+9;
struct balloon{
    long double x, r;
};
void solve(){
    int n;
    cin >> n;
    vector<balloon> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i].x >> a[i].r;
    }
    cout << fixed << setprecision(3);
    auto sqr = [&](long double x) -> long double{
        return x*x;
    };
    stack<int> st;
    vector<long double> ans(n+1);
    for(int i = 1; i <= n; i++){
        long double r = a[i].r;
        while(!st.empty()){
            int id = st.top();
            r = min(r, sqr(a[i].x-a[id].x)/(ans[id]*4));
            if(r >= ans[id]){
                st.pop();
            }else{
                break;
            }
        }
        ans[i] = r;
        cout << r << "\n";
        st.push(i);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...