結果
問題 |
No.2389 Cheating Code Golf
|
ユーザー |
|
提出日時 | 2023-07-21 23:58:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 1,154 bytes |
コンパイル時間 | 1,049 ms |
コンパイル使用メモリ | 92,588 KB |
最終ジャッジ日時 | 2025-02-15 17:48:03 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 |
ソースコード
/* なぜか合わない */ #include<iostream> #include<set> #include<map> #include<vector> #include<queue> #include<algorithm> #include<tuple> using namespace std; typedef long long ll; const ll INF=1LL<<60; int main(){ int N,M; cin>>N>>M; vector<int> A(N),B(N),P(N); for(int i=0;i<N;i++){ cin>>A[i]>>B[i]>>P[i]; } vector<vector<double>> dp(1<<N,vector<double>(M+1,-INF)); //0問正解.0回ミスしてOK for(int i=0;i<=M;i++){ dp[0][i]=0; } for(int S=0;S<(1<<N);S++){ for(int j=0;j<=M;j++){ for(int k=0;k<N;k++){ if(((S>>k)&1)==1){ if(j>0){ double p=1.0/P[k]; dp[S][j]=max(dp[S][j], (dp[S^(1<<k)][j] + 1.0/B[k])*p + dp[S][j-1]*(1.0-p)); } //j==0 dp[S][j]=max(dp[S][j],(dp[S^(1<<k)][j]+1.0/A[k])); } } } } double ans=dp[(1<<N)-1][M]; printf("%.10f\n",ans); }