結果
問題 | No.1151 チャレンジゲーム |
ユーザー | opt |
提出日時 | 2020-08-08 00:51:55 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 60 ms / 2,000 ms |
コード長 | 3,837 bytes |
コンパイル時間 | 2,095 ms |
コンパイル使用メモリ | 210,164 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 02:54:52 |
合計ジャッジ時間 | 5,077 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 1 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 19 ms
6,940 KB |
testcase_14 | AC | 18 ms
6,940 KB |
testcase_15 | AC | 18 ms
6,944 KB |
testcase_16 | AC | 19 ms
6,940 KB |
testcase_17 | AC | 19 ms
6,944 KB |
testcase_18 | AC | 19 ms
6,944 KB |
testcase_19 | AC | 19 ms
6,940 KB |
testcase_20 | AC | 19 ms
6,944 KB |
testcase_21 | AC | 19 ms
6,944 KB |
testcase_22 | AC | 19 ms
6,944 KB |
testcase_23 | AC | 19 ms
6,944 KB |
testcase_24 | AC | 19 ms
6,940 KB |
testcase_25 | AC | 19 ms
6,944 KB |
testcase_26 | AC | 18 ms
6,940 KB |
testcase_27 | AC | 18 ms
6,940 KB |
testcase_28 | AC | 57 ms
6,944 KB |
testcase_29 | AC | 54 ms
6,944 KB |
testcase_30 | AC | 55 ms
6,944 KB |
testcase_31 | AC | 53 ms
6,940 KB |
testcase_32 | AC | 60 ms
6,940 KB |
testcase_33 | AC | 56 ms
6,940 KB |
testcase_34 | AC | 57 ms
6,944 KB |
testcase_35 | AC | 57 ms
6,940 KB |
testcase_36 | AC | 57 ms
6,940 KB |
testcase_37 | AC | 55 ms
6,940 KB |
testcase_38 | AC | 57 ms
6,944 KB |
testcase_39 | AC | 58 ms
6,940 KB |
testcase_40 | AC | 57 ms
6,944 KB |
testcase_41 | AC | 55 ms
6,940 KB |
testcase_42 | AC | 56 ms
6,940 KB |
testcase_43 | AC | 57 ms
6,940 KB |
testcase_44 | AC | 54 ms
6,940 KB |
testcase_45 | AC | 58 ms
6,940 KB |
testcase_46 | AC | 59 ms
6,940 KB |
testcase_47 | AC | 56 ms
6,944 KB |
testcase_48 | AC | 54 ms
6,940 KB |
testcase_49 | AC | 53 ms
6,940 KB |
testcase_50 | AC | 57 ms
6,940 KB |
testcase_51 | AC | 58 ms
6,944 KB |
testcase_52 | AC | 55 ms
6,940 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using V = vector<int>; using Vll = vector<ll>; using Vld = vector<ld>; using Vbo = vector<bool>; using VV = vector<V>; using VVll = vector<Vll>; using VVld = vector<Vld>; using VVbo = vector<Vbo>; using VVV = vector<VV>; using VVVll = vector<VVll>; using VVVld = vector<VVld>; using P = pair<int, int>; using Pll = pair<ll, ll>; using Pld = pair<ld, ld>; #define rep2(i, m, n) for (int i = (m); i < (n); ++i) #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define rep(i, n) rep2(i, 0, n) #define drep(i, n) drep2(i, n, 0) #define all(a) (a).begin(), (a).end() struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; template<typename T> inline int sz(T &x) { return x.size(); } template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; } template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; } template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; } template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; } template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r) inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x)) inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); } inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x)) inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); } inline int popcount(const int x) { return __builtin_popcount(x); } inline int popcount(const ll x) { return __builtin_popcountll(x); } void fail() { puts("-1"); exit(0); } // const int INF = 1<<30; // const ll INFll = 1ll<<62; // const ld EPS = 1e-10; // const ld PI = acos(-1.0); // const int MOD = int(1e9)+7; // const int MOD = 998244353; V convert(ll x, int b, int n) { V res; for (int i = 0; i < n; ++i) { res.push_back(x%b); x /= b; } return res; } int main() { int n; cin >> n; V a(n); cin >> a; Vld b(n); rep(i, n) b[i] = ld(1) / a[i]; int N = 1; rep(i, n) N *= 3; VVld p(2, Vld(N, -1)); rep(S, N) { V v = convert(S, 3, n); bool ini = true; rep(i, n) if (v[i] == 0) ini = false; if (!ini) { p[0][S] = 0; p[1][S] = 1; continue; } V s(2); rep(i, n) s[v[i]-1] += a[i]; if (s[0] <= s[1]) p[0][S] = 0, p[1][S] = 0; else p[0][S] = 1, p[1][S] = 1; } V pw3(n); pw3[0] = 1; rep(i, n-1) pw3[i+1] = pw3[i] * 3; drep(S, N) { V v = convert(S, 3, n); rep(i, n) if (v[i] == 0) { ld cmin = 1; rep(j, n) if (v[j] == 0) { int x = S + pw3[i]; int y = S + pw3[j] * 2; ld now = p[1][x] * b[i] + p[0][y] * (1-b[i]) * b[j]; now /= 1 - (1-b[i]) * (1-b[j]); chmin(cmin, now); } chmax(p[0][S], cmin); } rep(j, n) if (v[j] == 0) { ld cmax = 0; rep(i, n) if (v[i] == 0) { int x = S + pw3[i]; int y = S + pw3[j] * 2; ld now = p[0][y] * b[j] + p[1][x] * (1-b[j]) * b[i]; now /= 1 - (1-b[i]) * (1-b[j]); chmax(cmax, now); } chmin(p[1][S], cmax); } } cout << p[0][0] << '\n'; return 0; }