Submission #842504

# Submission time Handle Problem Language Result Execution time Memory
842504 2023-09-03T01:38:19 Z NoLove Balloons (CEOI11_bal) C++14
100 / 100
699 ms 6740 KB
/**
 *    author : Lăng Trọng Đạt
 *    created: 2023-09-02
**/
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
const int MAXN = 2e5 + 5;
int x[MAXN], r[MAXN];// f[i]: final radius of balloon i
double f[MAXN];
int n;

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);

    std::cin >> n;
    for (int i = 1; i <= n; i++) {
        std::cin >> x[i] >> r[i];
    }
    vector<int> s; // index of previous inflated balloon need to check, it will be decresing radius from top
    for (int b = 1; b <= n; b++) {
        f[b] = r[b];
        while (!s.empty() && f[b] >= f[s.back()]) {
            int a = s.back();
            f[b] = min(f[b], (x[b] - x[a]) * (x[b] - x[a]) / (4 * f[a]));
            if (f[b] >= f[s.back()])
                s.pop_back();
        }
        for (int a : s) {
            f[b] = min(f[b], (x[b] - x[a]) * (x[b] - x[a]) / (4 * f[a]));
        }
        s.push_back(b);
        cout << fixed << setprecision(4) << f[b] << "\n";
    }

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4440 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 18 ms 4900 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 283 ms 5204 KB 50000 numbers
2 Correct 138 ms 5120 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 449 ms 5712 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 627 ms 5852 KB 115362 numbers
2 Correct 338 ms 5544 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 699 ms 6408 KB 154271 numbers
2 Correct 559 ms 6488 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 301 ms 6740 KB 200000 numbers
2 Correct 576 ms 6508 KB 199945 numbers