結果

問題 No.2462 七人カノン
ユーザー Nzt3Nzt3
提出日時 2023-09-09 14:29:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 861 bytes
コンパイル時間 2,324 ms
コンパイル使用メモリ 212,776 KB
実行使用メモリ 11,328 KB
最終ジャッジ日時 2023-09-09 14:29:48
合計ジャッジ時間 9,674 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,384 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 138 ms
10,324 KB
testcase_14 AC 144 ms
10,300 KB
testcase_15 AC 141 ms
10,080 KB
testcase_16 AC 155 ms
10,504 KB
testcase_17 AC 156 ms
10,488 KB
testcase_18 AC 37 ms
4,380 KB
testcase_19 AC 37 ms
4,380 KB
testcase_20 AC 82 ms
4,848 KB
testcase_21 AC 82 ms
5,184 KB
testcase_22 AC 86 ms
5,156 KB
testcase_23 AC 83 ms
5,340 KB
testcase_24 AC 112 ms
10,744 KB
testcase_25 AC 163 ms
11,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
}
0