Submission #941154

# Submission time Handle Problem Language Result Execution time Memory
941154 2024-03-08T08:14:36 Z agawron Balloons (CEOI11_bal) C++14
30 / 100
110 ms 4948 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], max_r});

        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 Correct 1 ms 2392 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2396 KB 504th numbers differ - expected: '160.9360000000', found: '163.0000000000', error = '2.0640000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2652 KB 653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 3164 KB 50000 numbers
2 Incorrect 25 ms 4164 KB 49903rd numbers differ - expected: '443977872.4679999948', found: '1000000000.0000000000', error = '556022127.5320000648'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 3788 KB 14857th numbers differ - expected: '7169.6020000000', found: '7176.0000000000', error = '6.3980000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 4072 KB 23610th numbers differ - expected: '1467.9600000000', found: '1471.0000000000', error = '3.0400000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 4432 KB 12335th numbers differ - expected: '4957.2960000000', found: '4967.0000000000', error = '9.7040000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 110 ms 4948 KB 7553rd numbers differ - expected: '198.8980000000', found: '220.0000000000', error = '21.1020000000'
2 Halted 0 ms 0 KB -