結果

問題 No.2462 七人カノン
ユーザー planesplanes
提出日時 2023-09-08 21:40:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 237 ms / 2,000 ms
コード長 928 bytes
コンパイル時間 1,636 ms
コンパイル使用メモリ 175,048 KB
実行使用メモリ 10,136 KB
最終ジャッジ日時 2023-09-08 21:40:57
合計ジャッジ時間 11,152 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,604 KB
testcase_01 AC 3 ms
4,488 KB
testcase_02 AC 3 ms
4,448 KB
testcase_03 AC 5 ms
4,552 KB
testcase_04 AC 5 ms
4,728 KB
testcase_05 AC 5 ms
4,588 KB
testcase_06 AC 5 ms
4,572 KB
testcase_07 AC 5 ms
4,624 KB
testcase_08 AC 5 ms
4,608 KB
testcase_09 AC 4 ms
4,528 KB
testcase_10 AC 4 ms
4,532 KB
testcase_11 AC 5 ms
4,600 KB
testcase_12 AC 5 ms
4,616 KB
testcase_13 AC 191 ms
8,824 KB
testcase_14 AC 222 ms
9,144 KB
testcase_15 AC 200 ms
8,796 KB
testcase_16 AC 228 ms
9,584 KB
testcase_17 AC 234 ms
9,504 KB
testcase_18 AC 177 ms
7,048 KB
testcase_19 AC 174 ms
6,924 KB
testcase_20 AC 222 ms
10,036 KB
testcase_21 AC 220 ms
10,104 KB
testcase_22 AC 225 ms
10,116 KB
testcase_23 AC 226 ms
10,136 KB
testcase_24 AC 207 ms
8,480 KB
testcase_25 AC 237 ms
10,048 KB
権限があれば一括ダウンロードができます

ソースコード

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