답안 #988838

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
988838 2024-05-26T12:35:33 Z _callmelucian Balloons (CEOI11_bal) C++14
20 / 100
392 ms 12112 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tt;

#define all(a) a.begin(), a.end()
#define filter(a) a.erase(unique(all(a)), a.end())

const ld INF = 1e18;
const ld eps = 1e-9;
const int mn = 2e5 + 5;

ll x[mn], maxR[mn];
ld rad[mn];

bool ok (int j, int i, ld tryR) {
    ld tmp = (x[i] - x[j]) * (x[i] - x[j]);
    return tmp - 4 * rad[j] * tryR >= -eps;
}

ld calc (int j, int i, ld L = 0, ld R = INF) {
    if (abs(L - R) < eps) return L;
    ld mid = (L + R) / 2;
    if (ok(j, i, mid + eps)) return calc(j, i, mid + eps, R);
    return calc(j, i, L, mid);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n; cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> x[i] >> maxR[i];
    rad[1] = maxR[1];

    cout << fixed << setprecision(9) << rad[1] << "\n";

    vector<int> vec = {1};
    for (int i = 2; i <= n; i++) {
        rad[i] = INF;
        int save = -1;
        for (int j = vec.size() - 1; j >= 0; j--) {
            ld cur = calc(vec[j], i, 0, maxR[i]);
            if (cur < rad[i] + eps) {
                rad[i] = cur;
                save = vec[j];
                vec.pop_back();
            }
            else break;
        }
        vec.push_back(save);
        vec.push_back(i);

        cout << rad[i] << "\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB 10 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 17th numbers differ - expected: '213.0000000000', found: '234.0000000000', error = '21.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 344 KB 114th numbers differ - expected: '39.0180000000', found: '56.0000000000', error = '16.9820000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 1372 KB 653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 89 ms 3408 KB 14174th numbers differ - expected: '0.7720000000', found: '1.3705055140', error = '0.5985055140'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 187 ms 7760 KB 7466th numbers differ - expected: '2.8320000000', found: '3.7068369940', error = '0.8748369940'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 211 ms 7372 KB 4793rd numbers differ - expected: '0.9540000000', found: '10.6222724340', error = '9.6682724340'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 299 ms 10320 KB 1785th numbers differ - expected: '2.2550000000', found: '10.0000000000', error = '7.7450000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 392 ms 12112 KB 2723rd numbers differ - expected: '859.0470000000', found: '862.0000000000', error = '2.9530000000'
2 Halted 0 ms 0 KB -