結果

問題 No.2462 七人カノン
ユーザー shobonvipshobonvip
提出日時 2023-09-08 22:13:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 2,170 ms
コンパイル使用メモリ 201,988 KB
実行使用メモリ 6,252 KB
最終ジャッジ日時 2023-09-08 22:13:30
合計ジャッジ時間 10,766 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 3 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 4 ms
4,384 KB
testcase_05 AC 4 ms
4,476 KB
testcase_06 AC 4 ms
4,548 KB
testcase_07 AC 4 ms
4,520 KB
testcase_08 AC 4 ms
4,540 KB
testcase_09 AC 3 ms
4,532 KB
testcase_10 AC 4 ms
4,384 KB
testcase_11 AC 4 ms
4,520 KB
testcase_12 AC 4 ms
4,536 KB
testcase_13 AC 116 ms
5,992 KB
testcase_14 AC 124 ms
5,780 KB
testcase_15 AC 115 ms
5,908 KB
testcase_16 AC 133 ms
6,252 KB
testcase_17 AC 134 ms
6,088 KB
testcase_18 AC 53 ms
4,768 KB
testcase_19 AC 52 ms
4,884 KB
testcase_20 AC 121 ms
6,204 KB
testcase_21 AC 121 ms
6,092 KB
testcase_22 AC 125 ms
6,040 KB
testcase_23 AC 121 ms
6,036 KB
testcase_24 AC 94 ms
5,640 KB
testcase_25 AC 135 ms
6,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
	int n, q; cin >> n >> q;
	const int mx = 100003;
	vector<int> I(q), S(q), T(q);
	vector<int> imos(mx);
	for(int i=0; i<q; i++){
		cin >> I[i] >> S[i] >> T[i];
		I[i]--;
		imos[S[i]]++;
		imos[T[i]]--;
	}
	for(int i=0; i<mx-1; i++){
		imos[i+1] += imos[i];
	}
	vector<double> rui(mx+1);
	for(int i=0; i<mx; i++){
		if (imos[i] > 0){
			rui[i+1] = rui[i] + (double)1 / imos[i];
		}else{
			rui[i+1] = rui[i];
		}
	}
	vector<double> ans(n);
	for (int i=0; i<q; i++){
		ans[I[i]] += rui[T[i]] - rui[S[i]];
	}
	cout << fixed << setprecision(15);
	for (int i=0; i<n; i++){
		cout << ans[i] << '\n';
	}
}
0