제출 #1295801

#제출 시각아이디문제언어결과실행 시간메모리
1295801KindaGoodGamesBalloons (CEOI11_bal)C++20
10 / 100
2097 ms12704 KiB
#include<bits/stdc++.h>

#define ll long long
#define double long double
#define pii pair<int,double>
#define pdd pair<double,double>
#define tiii tuple<int,int,int>

using namespace std;

double eps = 1e-6;

double dist(pdd a, pdd b){
    double dx = a.first-b.first;
    double dy = a.second-b.second;
    return sqrt((dx*dx)+(dy*dy));
}

double get(pii bal, int p){
    // double l = 0;
    // double r = 1e9;
    
    // pdd point = {bal.first, bal.second};
    // double ma = 0;
    // while(r-l >= eps){
    //     double mid = (r+l)/2;
    //     pdd po = {p,mid};
        
    //     double d = dist(point, po);
    //     if(d >= mid+bal.second){
    //         ma = max(ma, mid);
    //         l = mid+eps;
    //     }else{
    //         r = mid-eps;
    //     }
    // }
    // return l;

    double top = (bal.first-p)*(bal.first-p);
    return (top/(4*bal.second));
}

int main(){
    int n;
    cin >> n;

    vector<int> arr(n);
    vector<double> constr(n);

    for(int i = 0; i < n; i++){
        cin >> arr[i] >> constr[i];
    }

    cout << fixed << setprecision(3);

    deque<pii> S;
    for(int i = 0; i < n; i++){
        double val = 1e9;
        int l = 1; int r = S.size()-1;
        while(S.size() >= 2 && get(S.back(), arr[i]) > get(S[S.size()-2],arr[i])){ 
            S.pop_back();
        } 
        while(S.size() >= 2 && get(S[0], arr[i]) > get(S[1],arr[i])){ 
            S.pop_front();
        } 
        if(S.size()) val = min(val, get(S.back(),arr[i]));
        if(S.size()) val = min(val, get(S.front(),arr[i]));
        val = min(val, constr[i]);
        while(S.size() && S.back().second <= val){
            S.pop_back();
        }
        S.push_back({arr[i],val});
        cout << val << "\n";
    }
    
}
#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...