Submission #482388

# Submission time Handle Problem Language Result Execution time Memory
482388 2021-10-24T09:06:48 Z chungdinh Balloons (CEOI11_bal) C++17
100 / 100
565 ms 11204 KB
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <algorithm>
#include <iostream>
#include <cstring>

using namespace std;

#define ll long long
#define ii pair<int, int>
#define FOR(i, l, r) for (int i = (l); i <= (r); i++)
#define all(x) x.begin(), x.end()

const int N = 5e5 + 5;
const ll MOD = 998244353;

int n;
pair<long double, long double> a[N];
long double z[N];

int main() {
    #ifdef CHUNGDINH
    freopen("main.inp","r",stdin);
    #endif // CHUNGDINH

    stack<int> st;

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].first >> a[i].second;

        long double &r = z[i];
        r = a[i].second;

        while (st.size()) {
            int u = st.top();
            r = min(r, (a[i].first - a[u].first) * (a[i].first - a[u].first) / 4 / z[u]);
            if (r >= z[u]) st.pop(); else break;
        }
        st.push(i);

        printf("%.3Lf\n", r);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 6 ms 420 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 57 ms 1384 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 138 ms 3028 KB 50000 numbers
2 Correct 174 ms 2936 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 264 ms 5884 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 324 ms 6784 KB 115362 numbers
2 Correct 323 ms 6624 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 441 ms 8864 KB 154271 numbers
2 Correct 552 ms 10916 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 565 ms 11204 KB 200000 numbers
2 Correct 539 ms 10816 KB 199945 numbers