Submission #312523

# Submission time Handle Problem Language Result Execution time Memory
312523 2020-10-13T16:15:27 Z fatemetmhr Balloons (CEOI11_bal) C++17
0 / 100
568 ms 11960 KB
#include<bits/stdc++.h>
#define sanastd using namespace std
sanastd;

const int MAXN = 1000 * 1000 + 10;
const long long INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;

int n, r[MAXN], x[MAXN];
long double ans[MAXN];
stack <int> balloon;

bool check(int ind1, int ind2, double mid)
{
    long double d = (x[ind1] - x[ind2]) * (x[ind1] - x[ind2]) + (ans[ind2] - mid) * (ans[ind2] - mid);
    if(sqrt(d) < mid + ans[ind2]) return 0;
    else return 1;
}
int main ()
{
    cout<<fixed<<setprecision(15);
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin >> n >> x[0] >> r[0];
    balloon.push(0);
    ans[0] = r[0];
    cout << r[0] << endl;
    for(int i = 1; i < n; i++){
        cin >> x[i] >> r[i];
        ans[i] = r[i];
        while(!balloon.empty() and r[balloon.top()] <= ans[i]){
            long double lo = 0, hi = r[i] + 0.001;
            while(hi - lo > 0.001){
                long double mid = (hi + lo) / 2.0;
                if(check(i, balloon.top(), mid)) lo = mid;
                else hi = mid;
            }
            ans[i] = min(ans[i], lo);
            balloon.pop();
        }
        if(!balloon.empty()){
            long double lo = 0, hi = r[i] + 0.001;
            while(hi - lo > 0.001){
                long double mid = (hi + lo) / 2.0;
                if(check(i, balloon.top(), mid)) lo = mid;
                else hi = mid;
            }
            ans[i] = min(ans[i], lo);
        }
        balloon.push(i);
        cout << ans[i] << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB 5th numbers differ - expected: '17.1630000000', found: '99.0000000000', error = '81.8370000000'
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB 2nd numbers differ - expected: '252735385.4379999936', found: '0.9331415640', error = '252735384.5048584342'
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB 5th numbers differ - expected: '0.1170000000', found: '1.0000000000', error = '0.8830000000'
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 512 KB 114th numbers differ - expected: '39.0180000000', found: '39.0279185944', error = '0.0099185944'
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 1528 KB 56th numbers differ - expected: '153.0020000000', found: '153.0001057764', error = '0.0018942236'
# Verdict Execution time Memory Grader output
1 Incorrect 187 ms 3320 KB 5th numbers differ - expected: '15395.0000000000', found: '0.0000000000', error = '15395.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 357 ms 6212 KB 52nd numbers differ - expected: '7880.0000000000', found: '978.5282328722', error = '6901.4717671278'
# Verdict Execution time Memory Grader output
1 Incorrect 453 ms 7200 KB 66th numbers differ - expected: '4988.0000000000', found: '4987.9979484882', error = '0.0020515118'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 568 ms 9524 KB 347th numbers differ - expected: '1504.0000000000', found: '1504.0018552235', error = '0.0018552235'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 503 ms 11960 KB 54th numbers differ - expected: '2907.0000000000', found: '2906.9980543094', error = '0.0019456906'
2 Halted 0 ms 0 KB -