Submission #602622

# Submission time Handle Problem Language Result Execution time Memory
602622 2022-07-23T09:34:30 Z leroycut Balloons (CEOI11_bal) C++17
100 / 100
230 ms 14900 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

const ll N = 70000000, mod = 1e9 + 7, inf = 1e18 + 7;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    // freopen("forest.in", "r", stdin);
    // freopen("forest.out", "w", stdout);

    int n;
    cin >> n;
    vector<ld> r(n), x(n), ans(n);
    for(int i = 0; i < n; ++i) cin >> x[i] >> r[i];
    stack<pair<ld, ld>> st;
    for(int i = 0; i < n; ++i){
        ld rcur = r[i];
        
        while(!st.empty()){
            ld x1 = st.top().first, r1 = st.top().second;
            rcur = min(rcur, (x[i] - x1) * (x[i] - x1) / (4 * r1));
            if(rcur >= r1){
                st.pop();
            }else{
                break;
            }
        }
        st.push({x[i], rcur});
        ans[i] = rcur;
    }

    for(auto i : ans){
        cout << fixed << setprecision(3) << i << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 444 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1624 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 55 ms 4168 KB 50000 numbers
2 Correct 70 ms 3936 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 143 ms 7504 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 132 ms 8704 KB 115362 numbers
2 Correct 113 ms 9032 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 166 ms 11404 KB 154271 numbers
2 Correct 230 ms 14900 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 201 ms 14028 KB 200000 numbers
2 Correct 186 ms 14832 KB 199945 numbers