제출 #386047

#제출 시각아이디문제언어결과실행 시간메모리
386047ArianKheirandishBalloons (CEOI11_bal)C++14
100 / 100
229 ms10348 KiB
//in the name of god//
// SOBHET BEKHEIR JOOOOOOON E DEL

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long ll;
#define all(x)	x.begin(),x.end()
#define _ ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define pll pair<ll,ll>

const int maxn = 2e6 + 10;
const int MAX = 110;
const int inf = 1e9 + 10;
const int mod = 1e9 + 7;
int n;
double x[maxn], mxr[maxn], r[maxn];
stack < pair <double, double > > s;

int main(){_
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
        cin >> x[i] >> mxr[i];

    r[1] = mxr[1];
    s.push(MP(x[1], mxr[1]));

    for(int i = 2; i <= n ; i++){
        r[i] = mxr[i];

        while (!s.empty()) {
            auto top = s.top();
            double prevX = top.F;
            double prevR = top.S;

            r[i] = min(r[i], (x[i] - prevX)*(x[i] - prevX)/(4 * prevR));

            if (r[i] >= prevR)
                s.pop();

            else
                break;
        }

        s.push(MP(x[i], r[i]));
    }

    for(int i = 1 ; i <= n ; i ++)
        cout << fixed << setprecision(3) << r[i] << '\n';

    return 0;
}
#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...