Submission #1077194

# Submission time Handle Problem Language Result Execution time Memory
1077194 2024-08-27T02:44:44 Z serpent_121 Balloons (CEOI11_bal) C++17
100 / 100
458 ms 8788 KB
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <cmath>
#include <cstring>
#include <climits>
#include <stack>
#include <bitset>
#include <iomanip>
typedef long long ll;
using namespace std;
// https://oj.uz/problem/view/CEOI11_bal

const int PRECISION = 3;

int main() {
    ll n; cin >> n;
    stack<pair<double,long double>> s;
    for (int i = 0; i<n; i++) {
        double x,r; cin >> x >> r;
        long double constraint = r;
        while (!s.empty()) {
            long double c = (x-s.top().first)*(x-s.top().first)/(long double)(4*s.top().second);
            constraint = min(constraint,c);
            if (constraint > s.top().second) s.pop(); // we are sure that we can inflate to at least s.top().second
            else break; // now we are sure that a stronger constraint cannot be delivered
        }
        s.push({x,constraint});
        cout << fixed << setprecision(PRECISION);
        cout << constraint << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 44 ms 604 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 124 ms 1892 KB 50000 numbers
2 Correct 114 ms 2384 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 227 ms 2896 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 276 ms 3384 KB 115362 numbers
2 Correct 272 ms 5352 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 352 ms 4176 KB 154271 numbers
2 Correct 450 ms 8788 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 434 ms 4640 KB 200000 numbers
2 Correct 458 ms 8768 KB 199945 numbers