답안 #754410

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
754410 2023-06-07T17:38:43 Z PanosPask Balloons (CEOI11_bal) C++14
30 / 100
118 ms 7100 KB
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

typedef long long ll;

int n;
vector<int> active_circles;
vector<long double> radius;
vector<int> maxradius;
vector<int> position;

long double find_r2(int x1, long double r1, int x2)
{
    return ((ll)(x1 - x2) * (x1 - x2)) / (4 * r1);
}

long double allowed_radius(int i, int j)
{
    return find_r2(position[i], radius[i], position[j]);
}

int main(void)
{
    scanf("%d", &n);

    position.resize(n);
    maxradius.resize(n);
    radius.resize(n);

    for (int i = 0; i < n; i++) {
        scanf("%d %d", &position[i], &maxradius[i]);
    }

    for (int i = 0; i < n; i++) {
        bool foundbreak = false;

        while (active_circles.size() >= 2 && !foundbreak) {
            int mid = active_circles.back();
            int prv = active_circles[active_circles.size() - 2];

            if (allowed_radius(prv, i) <= allowed_radius(mid, i)) {
                active_circles.pop_back();
            }
            else
                foundbreak = true;
        }

        radius[i] = maxradius[i];
        if (!active_circles.empty())
            radius[i] = min(radius[i], allowed_radius(active_circles.back(), i));

        while (!active_circles.empty() && radius[active_circles.back()] <= radius[i])
            active_circles.pop_back();
        active_circles.pb(i);

        printf("%.3Lf\n", radius[i]);
    }

    return 0;
}

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
bal.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         scanf("%d %d", &position[i], &maxradius[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB 10 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 53rd numbers differ - expected: '213.0000000000', found: '235.0000000000', error = '22.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB 2000 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 1148 KB 4165th numbers differ - expected: '463.3780000000', found: '468.0000000000', error = '4.6220000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 32 ms 2400 KB 26317th numbers differ - expected: '1.1140000000', found: '16.4820000000', error = '15.3680000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 62 ms 4036 KB 7458th numbers differ - expected: '1.9040000000', found: '8.0000000000', error = '6.0960000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 75 ms 4588 KB 4889th numbers differ - expected: '0.7110000000', found: '8.0000000000', error = '7.2890000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 92 ms 5724 KB 40692nd numbers differ - expected: '5543.6460000000', found: '5559.0000000000', error = '15.3540000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 118 ms 7100 KB 4263rd numbers differ - expected: '0.6980000000', found: '4.0000000000', error = '3.3020000000'
2 Halted 0 ms 0 KB -