結果

問題 No.2462 七人カノン
ユーザー hiro71687khiro71687k
提出日時 2023-09-08 21:46:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 560 ms / 2,000 ms
コード長 1,342 bytes
コンパイル時間 4,291 ms
コンパイル使用メモリ 266,160 KB
実行使用メモリ 13,776 KB
最終ジャッジ日時 2023-09-08 21:47:02
合計ジャッジ時間 20,586 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,252 KB
testcase_01 AC 5 ms
6,348 KB
testcase_02 AC 5 ms
6,312 KB
testcase_03 AC 11 ms
6,308 KB
testcase_04 AC 10 ms
6,144 KB
testcase_05 AC 10 ms
6,280 KB
testcase_06 AC 10 ms
6,308 KB
testcase_07 AC 9 ms
6,108 KB
testcase_08 AC 9 ms
6,280 KB
testcase_09 AC 8 ms
6,276 KB
testcase_10 AC 9 ms
6,128 KB
testcase_11 AC 10 ms
6,356 KB
testcase_12 AC 10 ms
6,112 KB
testcase_13 AC 422 ms
12,700 KB
testcase_14 AC 471 ms
12,972 KB
testcase_15 AC 430 ms
13,168 KB
testcase_16 AC 494 ms
13,220 KB
testcase_17 AC 495 ms
13,188 KB
testcase_18 AC 272 ms
7,724 KB
testcase_19 AC 297 ms
7,868 KB
testcase_20 AC 524 ms
13,128 KB
testcase_21 AC 549 ms
13,040 KB
testcase_22 AC 556 ms
13,776 KB
testcase_23 AC 520 ms
13,060 KB
testcase_24 AC 406 ms
10,420 KB
testcase_25 AC 560 ms
13,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=1000000007;
ll inf=10090000000000000;
int main(){
    ll n,q;
    cin >> n >> q;
    vector<ll>x(q),s(q),t(q);
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>pq;
    for (ll i = 0; i < q; i++)
    {
        cin >> x[i] >> s[i]>> t[i];
        x[i]--;
        pq.push({s[i],1});
        pq.push({t[i],-1});
    }
    ld y=0;
    vector<ld>memo(100001,-1);
    while (!pq.empty())
    {
        pair<ll,ll>p=pq.top();
        pq.pop();
        y+=p.second;
        if (y==0)
        {
            memo[p.first]=0;
            continue;
        }
        memo[p.first]=1.0/y;
    }
    for (ll i = 1; i < memo.size(); i++)
    {
        if (memo[i]==-1)
        {
            memo[i]=memo[i-1];
        }
    }
    vector<ld>wa(memo.size(),0);
    wa[0]=memo[0];
    for (ll i = 1; i < wa.size(); i++)
    {
        wa[i]=wa[i-1]+memo[i];
    }
    vector<ld>ans(n,0);
    for (ll i = 0; i < q; i++)
    {
        if (s[i]==0)
        {
            ans[x[i]]+=wa[t[i]-1];
        }else{
            ans[x[i]]+=wa[t[i]-1]-wa[s[i]-1];
        }
    }
    for (ll i = 0; i < n; i++)
    {
        cout << setprecision(100) << ans[i] << endl;
    }
    
}
0