結果
問題 | No.1151 チャレンジゲーム |
ユーザー | opt |
提出日時 | 2020-08-07 23:06:47 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,828 bytes |
コンパイル時間 | 2,417 ms |
コンパイル使用メモリ | 209,996 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-24 23:42:35 |
合計ジャッジ時間 | 5,472 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | WA | - |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
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 | 55 ms
6,944 KB |
testcase_49 | AC | 52 ms
6,940 KB |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
ソースコード
#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) 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) { p[0][S] = 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) { p[1][S] = 1; 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; }