結果

問題 No.1151 チャレンジゲーム
ユーザー SHIJOUSHIJOU
提出日時 2020-08-11 16:01:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,225 bytes
コンパイル時間 2,328 ms
コンパイル使用メモリ 197,836 KB
実行使用メモリ 16,488 KB
最終ジャッジ日時 2024-04-17 17:24:28
合計ジャッジ時間 6,153 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const size_t N = 10;
const size_t X = 1024*201*2;

//head

int n;
int a[N];
int sum;
ld memo[X];

ld dfs(int info, int now, short kiri) {
  //cout << bitset<4>(info) << ' ' << now << ' ' << (kiri?"kiri":"null") << endl;
  if(info == 0) {
    if(kiri) {
      if(now >= (sum+1)/2) return 1;
      else return 0;
    } else {
      if(now >= sum/2+1) return 1;
      else return 0;
    }
  }
  int num = (info*201+now)*2+kiri;
  //if(memo[num] > -0.5) return memo[num];

  int sum = 0;
  rep(i, n) if(~info>>i&1) sum += a[i];
  ld aite[10];
  rep(i, n) if(info>>i&1) aite[i] = dfs(info^(1<<i), now, kiri);

  ld jj[10];
  memset(jj, 0, sizeof(jj));
  rep(i, n) if(info>>i&1) {
    if(a[i] == 1) jj[i] = 1-dfs(info^(1<<i), sum-now, 1^kiri);
    else {
      ld x = 1-dfs(info^(1<<i), sum-now, 1^kiri);
      ld nn[10];
      fill(nn, nn+10, 10);
      rep(j, n) if(info>>j&1) {
        nn[j] = (x*a[j]+aite[j]*(a[i]-1))/(a[i]+a[j]-1);
      }
      jj[i] = *min_element(nn, nn+10);
    }
  }
  return memo[num] = *max_element(jj, jj+10);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  fill(memo, memo+X, -1.0);
  cin >> n;
  rep(i, n) cin >> a[i];
  sum = accumulate(a, a+n, 0);
  cout << fixed << setprecision(10) << dfs((1<<n)-1, 0, 0) << endl;
}
0