Submission #1339204

#TimeUsernameProblemLanguageResultExecution timeMemory
1339204mernakBalloons (CEOI11_bal)C++20
20 / 100
113 ms8440 KiB
#include <bits/stdc++.h>
using namespace std;
namespace shortages {
    using ll = long long;
    using ull = unsigned long long;
    using uint = unsigned int;
    using ld = long double;

    template <typename T>
    using vec = vector<T>;

    template <typename T>
    using vv = vector<vector<T>>;

    template <typename T1, typename T2>
    ostream& operator<<(ostream& os, const pair<T1, T2>& pa) {
        os << pa.first << ' ' << pa.second;
        return os;
    }

    template <typename T1, typename T2>
    istream& operator>>(istream& is, pair<T1, T2>& pa) {
        is >> pa.first >> pa.second;
        return is;
    }

    template <typename T>
    ostream& operator<<(ostream& os, const vector<T>& vec) {
        for (size_t i = 0; i < vec.size(); ++i) {
            os << vec[i];
            if (i + 1 < vec.size())
                os << ' ';
        }
        os << '\n';
        return os;
    }

    template <typename T1, typename T2>
    ostream& operator<<(ostream& os, const vector<pair<T1, T2>>& vec) {
        for (size_t i = 0; i < vec.size(); ++i) {
            os << vec[i].first << ' ' << vec[i].second;
            if (i + 1 < vec.size())
                os << '\n';
        }
        return os;
    }

    template <typename T>
    ostream& operator<<(ostream& os, const vector<vector<T>>& vec) {
        for (size_t i = 0; i < vec.size(); ++i)
            os << vec[i];
        os << '\n';
        return os;
    }

    template <typename T>
    istream& operator>>(istream& is, vector<T>& vec) {
        for (auto& x : vec)
            is >> x;
        return is;
    }

    #define pint pair<int,int>
    #define pll pair<ll, ll>
    #define vi vec<int>
    #define vll vec<ll>
    #define vvi vec<vec<int>>
    #define vvll vec<vec<ll>>
    #define all(v) v.begin(), v.end()
}
using namespace shortages;

bool ith_bit(int n, int i) {
    return (n >> i) & 1;
}

void answer(bool ans) {
    if (ans)
        cout << "Yes\n";
    else
        cout << "No\n";
}


constexpr ll INF = 1e18;
constexpr ll M = 998244353;


void solve() {
    int n;
    cin >> n;
    vi a(n), r(n);
    vec<ld> t(n);
    for (int i = 0; i < n; i++)
        cin >> a[i] >> r[i];
    stack<int> s;
    for (int i = 0; i < n; ++i) {
        t[i] = r[i];
        while (!s.empty()) {
            t[i] = min(t[i], (a[i] - a[s.top()]) * (a[i] - a[s.top()]) / (4 * t[s.top()]));
            if (t[i] <= t[s.top()])
                break;
            s.pop();
        }
        s.push(i);
    }
    cout << fixed << setprecision(3);
    for (auto x : t)
        cout << x << '\n';
}


int main() {
    ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //freopen("paintbarn.in", "r", stdin);
    //freopen("paintbarn.out", "w", stdout);
    int test = 1;
    //cin >> test;
    while (test--)
        solve();
    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...