結果
問題 | No.2158 X日後に全完するhibit君 |
ユーザー | 沙耶花 |
提出日時 | 2022-12-09 21:54:25 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 201 ms / 2,000 ms |
コード長 | 1,358 bytes |
コンパイル時間 | 4,083 ms |
コンパイル使用メモリ | 262,404 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 21:44:38 |
合計ジャッジ時間 | 5,691 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 2000000000000000001 int main(){ int N,K; cin>>N>>K; vector<int> p(N),s(N),t(N); rep(i,N){ cin>>p[i]>>s[i]>>t[i]; } int mm = 1; rep(i,N)mm *= 6; vector<double> dp(mm,0.0); dp[0] = 1.0; int x = Inf32,y = -Inf32; double z = 0.0; rep(i,50){ vector<double> ndp(mm,0.0); rep(j,mm){ if(dp[j]==0.0)continue; int tt = min(i,K); vector<int> nums(N); { int cc = j; rep(k,N){ nums[k] = cc%6; cc /= 6; } } rep(k,1<<N){ int sum = 0; double pp = 1.0; int to = 0; int cv = 1; rep(l,N){ if((k>>l)&1){ sum += t[l]; pp *= ((double)nums[l]-tt)/(p[l]-tt); to += cv * nums[l]; } else{ sum += s[l]; pp *= ((double)p[l]-nums[l])/(p[l]-tt); to += cv * (nums[l]+1); } cv *= 6; } if(pp==0.0)continue; if(sum <= 60){ x = min(x,i+1); y = max(y,i+1); z += dp[j]*pp*(i+1); continue; } ndp[to] += dp[j] * pp; } } swap(dp,ndp); } if(x==Inf32){ cout<<-1<<endl; return 0; } cout<<x<<' '<<y<<' '; cout<<fixed<<setprecision(11)<<z<<endl; return 0; }