Submission #312544

# Submission time Handle Problem Language Result Execution time Memory
312544 2020-10-13T16:50:29 Z fatemetmhr Balloons (CEOI11_bal) C++17
10 / 100
454 ms 9720 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 = ans[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);
            if(ans[i] >= r[balloon.top()]) balloon.pop();
        }
        if(!balloon.empty()){
            long double lo = 0, hi = ans[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 Correct 0 ms 384 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 0 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 12th numbers differ - expected: '110.0020000000', found: '109.9999712296', error = '0.0020287704'
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 1272 KB 56th numbers differ - expected: '153.0020000000', found: '153.0001057764', error = '0.0018942236'
# Verdict Execution time Memory Grader output
1 Incorrect 122 ms 2720 KB 104th numbers differ - expected: '15293.0000000000', found: '15292.9981700143', error = '0.0018299857'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 249 ms 5112 KB 188th numbers differ - expected: '7737.0000000000', found: '7736.9978729417', error = '0.0021270583'
# Verdict Execution time Memory Grader output
1 Incorrect 298 ms 6036 KB 324th numbers differ - expected: '4706.0000000000', found: '4705.9980900586', error = '0.0019099414'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 390 ms 7816 KB 44th numbers differ - expected: '1831.0000000000', found: '1830.9977906367', error = '0.0022093633'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 454 ms 9720 KB 873rd numbers differ - expected: '2009.0000000000', found: '2008.9978989921', error = '0.0021010079'
2 Halted 0 ms 0 KB -