Submission #1236458

#TimeUsernameProblemLanguageResultExecution timeMemory
1236458MinhKienBalloons (CEOI11_bal)C++20
0 / 100
480 ms1572 KiB
#include <iostream>
#include <math.h>
#include <stack>

using namespace std;

struct bb {
    long double x, r;

    bb () {}
    bb (long double X, long double R) {
        x = X;
        r = R;
    }
};

int n;
bb k;
stack <bb> st, tmp;

long double dis(bb A, bb B) {
    return sqrt((A.x - B.x) * (A.x - B.x) + (A.r - B.r) * (A.r - B.r));
}

long double Find(bb kt) {
    return (kt.x - k.x) * (kt.x - k.x) / (4.0 * kt.r);
}

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

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> k.x >> k.r;

        long double ans;
        if (st.empty()) {
            printf("%.3f\n", k.r);
            ans = k.r;
        } else {
            ans = k.r;
            int cnt = 0;
            while (!st.empty()) {
                ++cnt;
                if (cnt > 400) break;

                ans = min(ans, Find(st.top()));
                tmp.push(st.top());
                st.pop();
            }

            while (!tmp.empty()) {
                st.push(tmp.top());
                tmp.pop();
            }

            while (!st.empty() && st.top().r < ans) st.pop();
            printf("%.3f\n", ans);
        }
        st.push(bb(k.x, ans));
    }

    return 0;
}

Compilation message (stderr)

bal.cpp: In function 'int main()':
bal.cpp:39:24: warning: format '%f' expects argument of type 'double', but argument 2 has type 'long double' [-Wformat=]
   39 |             printf("%.3f\n", k.r);
      |                     ~~~^     ~~~
      |                        |       |
      |                        double  long double
      |                     %.3Lf
bal.cpp:59:24: warning: format '%f' expects argument of type 'double', but argument 2 has type 'long double' [-Wformat=]
   59 |             printf("%.3f\n", ans);
      |                     ~~~^     ~~~
      |                        |     |
      |                        |     long double
      |                        double
      |                     %.3Lf
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...