結果
| 問題 |
No.2462 七人カノン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-09 14:29:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 137 ms / 2,000 ms |
| コード長 | 861 bytes |
| コンパイル時間 | 1,781 ms |
| コンパイル使用メモリ | 207,472 KB |
| 最終ジャッジ日時 | 2025-02-16 20:38:44 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,Q;
cin>>N>>Q;
vector<array<int,3>>I(Q);
for(auto &i:I)cin>>i[0]>>i[1]>>i[2],--i[0];
map<int,int>cnt;
for(auto i:I){
cnt[i[1]]+=1;
cnt[i[2]]-=1;
}
vector e_time(1,-1);
vector e_cnt(1,0.0);
double c=0;
for(auto i:cnt){
if(c==0){
e_cnt.push_back(0);
}else{
e_cnt.push_back((i.first-e_time.back())/c);
}
e_time.push_back(i.first);
c+=i.second;
}
for(int i=0;i<e_cnt.size()-1;i++){
e_cnt[i+1]+=e_cnt[i];
}
vector ans(N,0.0);
for(auto i:I){
ans[i[0]]+=e_cnt[lower_bound(e_time.begin(),e_time.end(),i[2])-e_time.begin()]-e_cnt[lower_bound(e_time.begin(),e_time.end(),i[1])-e_time.begin()];
}
cout<<setprecision(10);
for(auto i:ans)cout<<i<<'\n';
}