結果

問題 No.1151 チャレンジゲーム
ユーザー SHIJOUSHIJOU
提出日時 2020-08-11 16:00:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 2,223 bytes
コンパイル時間 2,524 ms
コンパイル使用メモリ 196,492 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-04-17 17:24:21
合計ジャッジ時間 5,592 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
10,112 KB
testcase_01 AC 6 ms
10,112 KB
testcase_02 AC 6 ms
10,264 KB
testcase_03 AC 6 ms
10,116 KB
testcase_04 AC 6 ms
10,108 KB
testcase_05 AC 6 ms
10,204 KB
testcase_06 AC 6 ms
10,112 KB
testcase_07 AC 6 ms
10,112 KB
testcase_08 AC 7 ms
10,208 KB
testcase_09 AC 7 ms
10,112 KB
testcase_10 AC 6 ms
10,240 KB
testcase_11 AC 6 ms
10,240 KB
testcase_12 AC 7 ms
10,260 KB
testcase_13 AC 19 ms
10,368 KB
testcase_14 AC 18 ms
10,112 KB
testcase_15 AC 17 ms
10,172 KB
testcase_16 AC 17 ms
10,332 KB
testcase_17 AC 19 ms
10,220 KB
testcase_18 AC 19 ms
10,112 KB
testcase_19 AC 17 ms
10,112 KB
testcase_20 AC 18 ms
10,112 KB
testcase_21 AC 16 ms
10,112 KB
testcase_22 AC 18 ms
10,148 KB
testcase_23 AC 17 ms
10,240 KB
testcase_24 AC 16 ms
10,240 KB
testcase_25 AC 16 ms
10,240 KB
testcase_26 AC 18 ms
10,240 KB
testcase_27 AC 19 ms
10,240 KB
testcase_28 AC 38 ms
10,112 KB
testcase_29 AC 39 ms
10,112 KB
testcase_30 AC 39 ms
10,112 KB
testcase_31 AC 32 ms
10,112 KB
testcase_32 AC 41 ms
10,240 KB
testcase_33 AC 45 ms
10,204 KB
testcase_34 AC 39 ms
10,208 KB
testcase_35 AC 45 ms
10,196 KB
testcase_36 AC 46 ms
10,256 KB
testcase_37 AC 46 ms
10,240 KB
testcase_38 AC 38 ms
10,160 KB
testcase_39 AC 36 ms
10,240 KB
testcase_40 AC 43 ms
10,112 KB
testcase_41 AC 34 ms
10,112 KB
testcase_42 AC 42 ms
10,368 KB
testcase_43 AC 38 ms
10,112 KB
testcase_44 AC 33 ms
10,272 KB
testcase_45 AC 41 ms
10,184 KB
testcase_46 AC 45 ms
10,240 KB
testcase_47 AC 39 ms
10,112 KB
testcase_48 AC 9 ms
10,172 KB
testcase_49 AC 13 ms
10,112 KB
testcase_50 AC 32 ms
10,240 KB
testcase_51 AC 46 ms
10,248 KB
testcase_52 AC 45 ms
10,280 KB
権限があれば一括ダウンロードができます

ソースコード

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