結果

問題 No.1151 チャレンジゲーム
ユーザー mtsd
提出日時 2020-08-07 22:42:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 2,730 bytes
コンパイル時間 1,031 ms
コンパイル使用メモリ 119,176 KB
実行使用メモリ 10,300 KB
最終ジャッジ日時 2024-09-24 22:56:48
合計ジャッジ時間 4,339 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
std::fill( (T*)array, (T*)(array+N), val );
}
template<class T> inline bool chmax(T &a, T b){
if(a<b){
a = b;
return true;
}
return false;
}
template<class T> inline bool chmin(T &a, T b){
if(a>b){
a = b;
return true;
}
return false;
}
double dp[1<<10][403][2];
int main(){
int n;
cin >> n;
vector<int> aa(n);
rep(i,n) cin >> aa[i];
rep(i,402){
rep(k,2){
if(i<=201){
dp[(1<<n)-1][i][k] = 0;
}else{
dp[(1<<n)-1][i][k] = 1;
}
}
}
for(int bits = (1<<n)-2;bits>=0;bits--){
for(int j=1;j<402;j++){
double mx = 0;
for(int x = 0; x<n;x++){
if((bits>>x)&1)continue;
double a = aa[x];
double hoge;
if(aa[x] + j >=402)hoge = 1.0;
else hoge = dp[bits^(1<<x)][aa[x]+j][1];
if(aa[x]==1){
double P = hoge;
chmax(mx,P);
continue;
}
double mi = 1.0;
for(int y=0;y<n;y++){
if((bits>>y)&1)continue;
double b = aa[y];
double hoge2;
if(j-aa[y]<0) hoge2 = 0;
else hoge2 = dp[bits^(1<<y)][j-aa[y]][0];
double P = (a*b)/(a+b-1.0) * ((1.0)/a*hoge + (a-1.0)/(a*b)*hoge2);
chmin(mi,P);
}
chmax(mx,mi);
}
dp[bits][j][0] = mx;
dp[bits][403-j][1] = 1.0-mx;
// if(j>=199&&j<=203){
// cerr << bits << " " << j << " " << 0 << " " << dp[bits][j][0] << endl;
// cerr << j - 201 << " " << (403-j) - 201 << endl;
// }
}
}
cout << fixed << setprecision(20) << dp[0][201][0] << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0