Submission #143005

# Submission time Handle Problem Language Result Execution time Memory
143005 2019-08-12T14:49:34 Z popovicirobert Balloons (CEOI11_bal) C++14
100 / 100
280 ms 8604 KB
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long



/*const int MOD = ;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}*/

/*int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}*/

using namespace std;

const double eps = 1e-4;
const int MAXN = (int) 2e5;

double cx[MAXN + 1], cy[MAXN + 1];

inline double inter(int a, int b) {
    return (cx[a] - cx[b]) * (cx[a] - cx[b]) / (4.0 * cy[b]);
}

int main() {
#if 0
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;
    stack <int> stk;
    for(i = 1; i <= n; i++) {
        cin >> cx[i] >> cy[i];
        while(stk.size()) {
            cy[i] = min(cy[i], inter(i, stk.top()));
            if(cy[stk.top()] - cy[i] > 0) {
                break;
            }
            stk.pop();
        }
        stk.push(i);
        cout << fixed << setprecision(3) << cy[i] << "\n";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 420 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 30 ms 1060 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 73 ms 2296 KB 50000 numbers
2 Correct 67 ms 2352 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 149 ms 4372 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 181 ms 4956 KB 115362 numbers
2 Correct 155 ms 5368 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 233 ms 6496 KB 154271 numbers
2 Correct 272 ms 8604 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 280 ms 7892 KB 200000 numbers
2 Correct 256 ms 8568 KB 199945 numbers