Submission #483474

# Submission time Handle Problem Language Result Execution time Memory
483474 2021-10-29T19:56:54 Z Shin Balloons (CEOI11_bal) C++14
20 / 100
182 ms 6840 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(), x.end()

using namespace std;
const int N = 2e5 + 7;
const int MOD = 1e9 + 7; // 998244353;
const int INF = 1e9 + 7;
const long long INFLL = 1e18 + 7;

template <class X, class Y> bool minimize(X &a, Y b) {
    if (a > b) return a = b, true;
    return false;
}
template <class X, class Y> bool maximize(X &a, Y b) {
    if (a < b) return a = b, true;
    return false;
}

#define SQR(x) (x) * (x)

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

void solve(void) {
    cin >> n;
    for (int i = 1; i <= n; i ++) {
        int l, r; cin >> l >> r;
        a[i] = mp(l, r * 1.0);
    }

    stack<pair<int, double>> st;
    st.push(a[1]);
    for (int i = 2; i <= n; i ++) {
        while (!st.empty()) {
            pair<int, double> pre = st.top();
            minimize(a[i].se, SQR(pre.fi - a[i].fi) / (4.0 * pre.se));
            if (a[i].se < pre.se) break;
            st.pop();
        }
        st.push(a[i]);
    }

    for (int i = 1; i <= n; i ++) {
        cout << fixed << setprecision(3) << a[i].se << '\n';
    }
}

int main(void) {
    cin.tie(0)->sync_with_stdio(0); 
    int test = 1;
    // cin >> test;
    while (test --) {
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB 2nd numbers differ - expected: '252735385.4379999936', found: '0.9330000000', error = '252735384.5049999952'
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB 506th numbers differ - expected: '365.0000000000', found: '-2481854.0649999999', error = '2482219.0649999999'
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1028 KB 655th numbers differ - expected: '591.0000000000', found: '-2402336.3029999998', error = '2402927.3029999998'
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 1688 KB 4th numbers differ - expected: '15396.0000000000', found: '-8148.5510000000', error = '23544.5510000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 3308 KB 7234th numbers differ - expected: '7160.0000000000', found: '-2398141.9989999998', error = '2405301.9989999998'
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 3872 KB 4643rd numbers differ - expected: '2427.0000000000', found: '-2355611.7020000000', error = '2358038.7020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 4952 KB 1734th numbers differ - expected: '1856.0220000000', found: '-2324667.3859999999', error = '2326523.4079999998'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 182 ms 6840 KB 2723rd numbers differ - expected: '859.0470000000', found: '-2333711.4849999999', error = '2334570.5319999997'
2 Halted 0 ms 0 KB -