Submission #941153

# Submission time Handle Problem Language Result Execution time Memory
941153 2024-03-08T08:13:46 Z agawron Balloons (CEOI11_bal) C++14
10 / 100
126 ms 7748 KB
#include<bits/stdc++.h>

using namespace std;
using pdd = pair <double, double>;

#define f first
#define s second

constexpr int MAX_N = 2e5 + 5;

double calc_r(pdd last, double cord){
    return (last.f - cord) * (last.f - cord)/(4 * last.s);
}

int n;
int x[MAX_N], r[MAX_N];
double ans[MAX_N];

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

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> x[i] >> r[i];
    }

    stack <pdd> st;

    for(int i = 0; i < n; i++){

        double max_r = r[i];

        while(st.size() > 0){
            pdd last = st.top();

            double to_last = calc_r(last, x[i]);

            max_r = min(max_r, to_last);

            if(last.s > to_last) break;
            else st.pop();
        }

        st.push({x[i], r[i]});

        ans[i] = max_r;
    }

    cout << fixed << setprecision(3);

    for(int i = 0; i < n; i++){
        cout << ans[i] << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB 5th numbers differ - expected: '17.1630000000', found: '4.3710000000', error = '12.7920000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB 3rd numbers differ - expected: '0.0420000000', found: '2.0830000000', error = '2.0410000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2396 KB 3rd numbers differ - expected: '121.0000000000', found: '120.0180000000', error = '0.9820000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 3164 KB 3rd numbers differ - expected: '211.0000000000', found: '210.0110000000', error = '0.9890000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 3924 KB 3rd numbers differ - expected: '15396.0000000000', found: '9489.3930000000', error = '5906.6070000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 5200 KB 3rd numbers differ - expected: '7936.0000000000', found: '6084.6240000000', error = '1851.3760000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 5596 KB 6th numbers differ - expected: '5053.0000000000', found: '5052.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 98 ms 6800 KB 3rd numbers differ - expected: '1872.0000000000', found: '1871.0010000000', error = '0.9990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 7748 KB 3rd numbers differ - expected: '2960.0000000000', found: '2959.0010000000', error = '0.9990000000'
2 Halted 0 ms 0 KB -