結果

問題 No.764 浮動点
ユーザー りあんりあん
提出日時 2018-11-28 08:16:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 1,500 ms
コード長 1,551 bytes
コンパイル時間 2,335 ms
コンパイル使用メモリ 201,528 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 12:50:42
合計ジャッジ時間 3,807 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

long double eps = 1e-12;

long double calc_area(long double l, long double r1, long double r2) {
    if (l + eps > r1 + r2) return 0;
    if (r1 + eps > l + r2) return (long double)M_PI * r2 * r2;
    if (r2 + eps > l + r1) return (long double)M_PI * r1 * r1;
    long double ct1 = (l * l + r1 * r1 - r2 * r2) / (2 * l * r1);
    long double ct2 = (l * l + r2 * r2 - r1 * r1) / (2 * l * r2);
    long double h = r1 * sqrtl(1 - ct1 * ct1);
    return r1 * r1 * acosl(ct1) + r2 * r2 * acosl(ct2) - l * h;
}

long double calc_area(long double l, long double r1s, long double r1l, long double r2s, long double r2l) {
    return calc_area(l, r1l, r2l) - calc_area(l, r1s, r2l) - calc_area(l, r1l, r2s) + calc_area(l, r1s, r2s);
}

int main() {
    int n;
    long long l;
    cin >> n >> l;
    assert(3 <= n && n <= 1000);
    assert(1 <= l && l <= 1000);
    vector<long long> v(n + 1), maxl(n + 2), maxr(n + 2), suml(n + 2), sumr(n + 2);
    for (int i = 0; i <= n; ++i) {
        cin >> v[i];
        assert(1 <= v[i] && v[i] <= 1000);
        maxl[i + 1] = max(maxl[i], v[i]);
        suml[i + 1] = suml[i] + v[i];
    }
    assert(getchar() == '\n');
    assert(getchar() == EOF);
    for (int i = n; i >= 0; --i) {
        maxr[i] = max(maxr[i + 1], v[i]);
        sumr[i] = sumr[i + 1] + v[i];
    }
    cout << setprecision(16);
    for (int i = 1; i <= n; ++i)
        cout << calc_area(l, max(maxl[i] * 2 - suml[i], 0LL), suml[i], max(maxr[i] * 2 - sumr[i], 0LL), sumr[i]) << "\n";

    return 0;
}
0