답안 #874650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
874650 2023-11-17T13:34:26 Z soyeb_p_jim Balloons (CEOI11_bal) C++14
0 / 100
1726 ms 1624 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_pair_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update>
void solve()
{
    ll n;
    cin >> n;
    stack<pair<ld, ld>> st;
    for (int i = 0; i < n; i++)
    {
        ld pos, r;
        cin >> pos >> r;
        ld red = r;
        if (st.size() == 0)
        {
            st.push({pos, red});
            printf("%.3Lf\n", red);
        }
        else
        {
            bool ck = 0;
            ld mn = r;
            while (st.size())
            {
                ld a = st.top().second;
                ld d = pos - st.top().first;
                ld rr = (d * d) / (4 * a);
                mn = min(mn, rr);
                if (rr < a)
                {
                    printf("%.3Lf\n", mn);
                    st.push({pos, mn});
                    ck = 1;
                    break;
                }
                else
                {
                    st.pop();
                }
                //cout << mn << " " << d << " " << a << "\n";
            }
            if (!ck)
            {
                st.push({pos, red});
                printf("%.3Lf\n", red);
            }
        }
    }
}
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    solve();
    return 0;
}
/*
    d^2 + (r-x)^2 = (r+x)^2
    d^2 / 4r = x
*/

Compilation message

bal.cpp: In function 'void solve()':
bal.cpp:23:25: warning: format '%Lf' expects argument of type 'long double', but argument 2 has type 'ld' {aka 'double'} [-Wformat=]
   23 |             printf("%.3Lf\n", red);
      |                     ~~~~^     ~~~
      |                         |     |
      |                         |     ld {aka double}
      |                         long double
      |                     %.3f
bal.cpp:37:33: warning: format '%Lf' expects argument of type 'long double', but argument 2 has type 'ld' {aka 'double'} [-Wformat=]
   37 |                     printf("%.3Lf\n", mn);
      |                             ~~~~^     ~~
      |                                 |     |
      |                                 |     ld {aka double}
      |                                 long double
      |                             %.3f
bal.cpp:51:29: warning: format '%Lf' expects argument of type 'long double', but argument 2 has type 'ld' {aka 'double'} [-Wformat=]
   51 |                 printf("%.3Lf\n", red);
      |                         ~~~~^     ~~~
      |                             |     |
      |                             |     ld {aka double}
      |                             long double
      |                         %.3f
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st numbers differ - expected: '24.0000000000', found: '0.0000000000', error = '24.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 1st numbers differ - expected: '247294217.0000000000', found: '0.0000000000', error = '247294217.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 348 KB 1st numbers differ - expected: '213.0000000000', found: '0.0000000000', error = '213.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 344 KB 1st numbers differ - expected: '123.0000000000', found: '0.0000000000', error = '123.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 200 ms 444 KB 1st numbers differ - expected: '213.0000000000', found: '0.0000000000', error = '213.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 428 ms 592 KB 1st numbers differ - expected: '15399.0000000000', found: '0.0000000000', error = '15399.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 886 ms 1288 KB 1st numbers differ - expected: '7938.0000000000', found: '0.0000000000', error = '7938.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1012 ms 1180 KB 1st numbers differ - expected: '5060.0000000000', found: '0.0000000000', error = '5060.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1364 ms 1436 KB 1st numbers differ - expected: '1874.0000000000', found: '0.0000000000', error = '1874.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1726 ms 1624 KB 1st numbers differ - expected: '2962.0000000000', found: '0.0000000000', error = '2962.0000000000'
2 Halted 0 ms 0 KB -