結果

問題 No.1151 チャレンジゲーム
ユーザー milanis48663220milanis48663220
提出日時 2020-08-07 22:42:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,681 bytes
コンパイル時間 862 ms
コンパイル使用メモリ 91,740 KB
実行使用メモリ 6,468 KB
最終ジャッジ日時 2023-10-25 03:28:36
合計ジャッジ時間 2,575 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

template <typename T>
class OffsetVec{
    public:
	int n;
    vector<T> v;
	T& operator[](int x) {
        return v[x+n];
	}
    void print(){
        for(int i = -n; i <= n; i++) cout << v[i+n] << ' ';
        cout << endl;
    }
    OffsetVec(int _n){
        n = _n;
        v = vector<T>(2*n+1);
    }
};

vector<OffsetVec<double>> dp;
int N;
double A[10];

const double eps = 1e-9;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < (1<<N); i++){
        dp.push_back(OffsetVec<double>(200));
    }
    for(int i = -200; i < 0; i++){
        dp[(1<<N)-1][i] = 0.0;
    }
    for(int i = 1; i <= 200; i++){
        dp[(1<<N)-1][i] = 1.0;
    }
    // kiriで終わる
    if(N%2 == 0) dp[(1<<N)-1][0] = 0.0;
    // nullで終わる
    if(N%2 == 1) dp[(1<<N)-1][0] = 1.0;
    for(int i = (1<<N)-2; i >= 0; i--){
        vector<int> rem, used;
        for(int j = 0; j < N; j++){
            if(i&(1<<j)) used.push_back(j);
            else rem.push_back(j);
        }
        for(int j = -200; j <= 200; j++){
            double tmp = 0.0;
            for(int k : rem){
                if(j+A[k] > 200) continue;
                double q = dp[i+(1<<k)][-j-A[k]];
                double p = 1/A[k];
                double cur = (1-p*q)/(2.0-p);
                tmp = max(tmp, cur);
            }
            dp[i][j] = tmp;
        }
    }
    
    cout << dp[0][0] << endl;
}
0