Submission #1116617

# Submission time Handle Problem Language Result Execution time Memory
1116617 2024-11-22T02:21:34 Z pemguimn Balloons (CEOI11_bal) C++14
0 / 100
4 ms 336 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;

int n, x[N], r[N];

long double ans[N];

long double calc(int i, int j){
    long double lo = 0, hi = r[j];
    long double dx = abs(x[j] - x[i]);
    for(int t = 0; t < 100; t++){
        long double mid = (lo + hi) / 2;
        long double dy = abs(mid - ans[i]);
        if(dx * dx + dy * dy >= (mid + ans[i]) * (mid + ans[i])){
            lo = mid;
        } else{
            hi = mid;   
        }
    }
    return lo;
}

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

    #ifndef Pemgu
        #define task "BALLOONS"
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    #endif // Pemgu

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

    stack<int> st;
    for(int i = 1; i <= n; i++){
        long double reach = r[i];
        for(int j = 1; j < i; j++){
          reach = min(reach, calc(j, i));
        }
        ans[i] = reach;
    }


    for(int i = 1; i <= n; i++)
        cout << setprecision(3) << fixed << ans[i] << "\n";

    return 0;
}

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 336 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 336 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -