답안 #754403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
754403 2023-06-07T17:17:25 Z PanosPask Balloons (CEOI11_bal) C++14
20 / 100
139 ms 10056 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));

        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 1 ms 212 KB 10 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 296 KB 17th numbers differ - expected: '213.0000000000', found: '234.0000000000', error = '21.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 312 KB 504th numbers differ - expected: '160.9360000000', found: '163.0000000000', error = '2.0640000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 1364 KB 653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 2932 KB 14174th numbers differ - expected: '0.7720000000', found: '1.3710000000', error = '0.5990000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 68 ms 5388 KB 7447th numbers differ - expected: '0.9750000000', found: '8.0000000000', error = '7.0250000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 75 ms 6180 KB 4793rd numbers differ - expected: '0.9540000000', found: '10.6220000000', error = '9.6680000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 93 ms 8520 KB 1734th numbers differ - expected: '1856.0220000000', found: '1865.0000000000', error = '8.9780000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 139 ms 10056 KB 2735th numbers differ - expected: '1883.4630000000', found: '1899.0000000000', error = '15.5370000000'
2 Halted 0 ms 0 KB -