結果

問題 No.2462 七人カノン
ユーザー planes
提出日時 2023-09-08 21:40:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 928 bytes
コンパイル時間 1,815 ms
コンパイル使用メモリ 176,012 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-06-26 14:34:03
合計ジャッジ時間 10,295 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

  #include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll INF=2e18;


int main() {
    ios::sync_with_stdio(false);
  cin.tie(0);
  ll N,Q;cin>>N>>Q;

  vector<ll> cnt(100000+10);
  
  vector<vector<pair<ll,ll>>> vec(N,vector<pair<ll,ll>> (0));
  for(ll i=0;i<Q;i++) {
    ll I,S,T;cin>>I>>S>>T;
    I--;
    vec[I].push_back(make_pair(S,T));
    cnt[S]++;
    cnt[T]--;
  }

  for(ll i=1;i<100000+10;i++) {
   cnt[i]+=cnt[i-1];
  }



vector<double> r(100000+10);
for(ll i=0;i<100000+10;i++) {
  if(cnt[i]==0) r[i]=0;
  else r[i]=1.0/cnt[i];
}

for(ll i=1;i<100000+10;i++) r[i]+=r[i-1];

cout<<fixed<<setprecision(10);
for(ll i=0;i<N;i++) {
  double ans=0;
  for(auto x:vec[i]) {
    if(x.first==0) ans+=r[x.second-1];
    else ans+=r[x.second-1]-r[x.first-1];
  }
  cout<<ans<<endl;
}
}


  


0