結果

問題 No.1151 チャレンジゲーム
ユーザー mtsdmtsd
提出日時 2020-08-07 22:42:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 2,730 bytes
コンパイル時間 1,159 ms
コンパイル使用メモリ 118,780 KB
実行使用メモリ 10,268 KB
最終ジャッジ日時 2023-10-25 03:27:42
合計ジャッジ時間 4,682 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 29 ms
8,584 KB
testcase_14 AC 29 ms
8,584 KB
testcase_15 AC 29 ms
8,584 KB
testcase_16 AC 28 ms
8,584 KB
testcase_17 AC 29 ms
8,584 KB
testcase_18 AC 29 ms
8,584 KB
testcase_19 AC 27 ms
8,584 KB
testcase_20 AC 29 ms
8,584 KB
testcase_21 AC 29 ms
8,584 KB
testcase_22 AC 29 ms
8,584 KB
testcase_23 AC 29 ms
8,584 KB
testcase_24 AC 26 ms
8,584 KB
testcase_25 AC 29 ms
8,584 KB
testcase_26 AC 29 ms
8,584 KB
testcase_27 AC 29 ms
8,584 KB
testcase_28 AC 62 ms
10,268 KB
testcase_29 AC 66 ms
10,268 KB
testcase_30 AC 67 ms
10,268 KB
testcase_31 AC 62 ms
10,268 KB
testcase_32 AC 67 ms
10,268 KB
testcase_33 AC 67 ms
10,268 KB
testcase_34 AC 61 ms
10,268 KB
testcase_35 AC 66 ms
10,268 KB
testcase_36 AC 67 ms
10,268 KB
testcase_37 AC 67 ms
10,268 KB
testcase_38 AC 67 ms
10,268 KB
testcase_39 AC 66 ms
10,268 KB
testcase_40 AC 66 ms
10,268 KB
testcase_41 AC 66 ms
10,268 KB
testcase_42 AC 67 ms
10,268 KB
testcase_43 AC 67 ms
10,268 KB
testcase_44 AC 67 ms
10,268 KB
testcase_45 AC 62 ms
10,268 KB
testcase_46 AC 68 ms
10,268 KB
testcase_47 AC 67 ms
10,268 KB
testcase_48 AC 12 ms
10,268 KB
testcase_49 AC 66 ms
10,268 KB
testcase_50 AC 62 ms
10,268 KB
testcase_51 AC 66 ms
10,268 KB
testcase_52 AC 62 ms
10,268 KB
権限があれば一括ダウンロードができます

ソースコード

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;
}
0