結果

問題 No.2462 七人カノン
ユーザー eve__fuyuki
提出日時 2024-04-16 11:29:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 910 bytes
コンパイル時間 1,967 ms
コンパイル使用メモリ 196,260 KB
最終ジャッジ日時 2025-02-21 02:28:33
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    fast_io();
    int n, q;
    cin >> n >> q;
    const int M = 1e5 + 5;
    vector<int> cnt(M);
    vector<int> I(q), S(q), T(q);
    for (int i = 0; i < q; i++) {
        cin >> I[i] >> S[i] >> T[i];
        I[i]--;
        cnt[S[i]]++;
        cnt[T[i]]--;
    }
    for (int i = 1; i < M; i++) {
        cnt[i] += cnt[i - 1];
    }
    vector<double> cum(M + 1);
    for (int i = 0; i < M; i++) {
        if (cnt[i] == 0) {
            cum[i + 1] = cum[i];
        } else {
            cum[i + 1] = cum[i] + (1.0 / cnt[i]);
        }
    }
    vector<double> ans(n);
    for (int i = 0; i < q; i++) {
        ans[I[i]] += cum[T[i]] - cum[S[i]];
    }
    cout << setprecision(16) << fixed;
    for (int i = 0; i < n; i++) {
        cout << ans[i] << "\n";
    }
}
0