結果

問題 No.2462 七人カノン
ユーザー Manuel1024
提出日時 2023-11-28 19:09:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 831 bytes
コンパイル時間 714 ms
コンパイル使用メモリ 79,524 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-09-26 13:03:45
合計ジャッジ時間 8,651 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
    int n, q; cin >> n >> q;
    vector<int> id(q), s(q), t(q);
    for(int i = 0; i < q; i++){
        cin >> id[i] >> s[i] >> t[i];
        id[i]--; s[i]++; t[i]++;
    }

    const int lim = 100010;
    vector<double> tot(lim, 0.0);
    vector<int> cnt(lim, 0);
    for(int i = 0; i < q; i++){
        cnt[s[i]]++;
        cnt[t[i]]--;
    }
    for(int i = 1; i < lim; i++) cnt[i] += cnt[i-1];
    for(int i = 0; i < lim-5; i++){
        if(0 < cnt[i]) tot[i] += 1.0/cnt[i];
        tot[i+1] += tot[i];
    }

    vector<double> ans(n, 0.0);
    for(int i = 0; i < q; i++){
        ans[id[i]] += tot[t[i]-1]-tot[s[i]-1];
    }

    for(auto &it: ans) cout << fixed << setprecision(10) << it << '\n';
    return 0;
}
0