結果

問題 No.2462 七人カノン
ユーザー PAKACHUPAKACHU
提出日時 2023-09-08 22:33:46
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 1,134 bytes
コンパイル時間 2,314 ms
コンパイル使用メモリ 135,116 KB
実行使用メモリ 13,716 KB
最終ジャッジ日時 2023-09-08 22:34:03
合計ジャッジ時間 13,495 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,548 KB
testcase_01 AC 5 ms
6,560 KB
testcase_02 AC 4 ms
6,516 KB
testcase_03 AC 7 ms
6,856 KB
testcase_04 AC 7 ms
6,936 KB
testcase_05 AC 7 ms
6,848 KB
testcase_06 AC 7 ms
6,812 KB
testcase_07 AC 7 ms
6,812 KB
testcase_08 AC 7 ms
6,796 KB
testcase_09 AC 6 ms
6,824 KB
testcase_10 AC 7 ms
6,820 KB
testcase_11 AC 7 ms
6,756 KB
testcase_12 AC 8 ms
6,748 KB
testcase_13 AC 242 ms
11,844 KB
testcase_14 AC 271 ms
12,568 KB
testcase_15 AC 241 ms
11,832 KB
testcase_16 AC 282 ms
12,560 KB
testcase_17 AC 280 ms
12,624 KB
testcase_18 AC 176 ms
10,516 KB
testcase_19 AC 176 ms
10,548 KB
testcase_20 AC 263 ms
13,712 KB
testcase_21 AC 265 ms
13,592 KB
testcase_22 AC 273 ms
13,640 KB
testcase_23 AC 263 ms
13,552 KB
testcase_24 AC 231 ms
12,208 KB
testcase_25 AC 285 ms
13,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const long long mod = 998244353;
const ll inf = 1LL << 60;
const int INF = 5e8;

int main()
{
    int n, q;
    cin >> n >> q;
    vector<vector<pair<int, int>>> v(n);
    vector<int> num(100010);
    while (q--) {
        int i, l, r;
        cin >> i >> l >> r;
        i--;
        v[i].emplace_back(l, r);
        num[l]++;
        num[r]--;
    }

    for (int i = 0; i <= 100000; i++)
        num[i + 1] += num[i];

    vector<ld> s(100010);
    for (int i = 0; i <= 100000; i++) {
        if (num[i] == 0)
            continue;
        s[i] = (ld)1 / num[i];
    }

    vector<ld> sm(100010);
    for (int i = 0; i <= 100000; i++) {
        sm[i + 1] = sm[i] + s[i];
    }

    vector<ld> ans(n);
    for (int i = 0; i < n; i++) {
        for (auto [l, r] : v[i]) {
            ans[i] += sm[r] - sm[l];
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%.18Lf", ans[i]);
        cout << endl;
    }
}
0