結果

問題 No.1590 Random Shopping
ユーザー risujirohrisujiroh
提出日時 2021-07-08 23:52:27
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 156 ms / 5,000 ms
コード長 1,065 bytes
コンパイル時間 2,082 ms
使用メモリ 6,952 KB
最終ジャッジ日時 2023-02-01 19:32:16
合計ジャッジ時間 5,447 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
4,900 KB
testcase_01 AC 2 ms
4,900 KB
testcase_02 AC 2 ms
6,952 KB
testcase_03 AC 2 ms
4,904 KB
testcase_04 AC 1 ms
4,900 KB
testcase_05 AC 2 ms
4,904 KB
testcase_06 AC 2 ms
4,900 KB
testcase_07 AC 2 ms
4,900 KB
testcase_08 AC 2 ms
6,952 KB
testcase_09 AC 2 ms
6,948 KB
testcase_10 AC 3 ms
4,904 KB
testcase_11 AC 4 ms
4,900 KB
testcase_12 AC 12 ms
4,900 KB
testcase_13 AC 42 ms
4,900 KB
testcase_14 AC 123 ms
5,708 KB
testcase_15 AC 124 ms
5,684 KB
testcase_16 AC 126 ms
6,952 KB
testcase_17 AC 122 ms
6,952 KB
testcase_18 AC 1 ms
4,900 KB
testcase_19 AC 156 ms
5,620 KB
testcase_20 AC 1 ms
4,900 KB
testcase_21 AC 89 ms
6,952 KB
testcase_22 AC 2 ms
4,900 KB
testcase_23 AC 123 ms
6,948 KB
testcase_24 AC 121 ms
5,616 KB
testcase_25 AC 2 ms
6,948 KB
testcase_26 AC 2 ms
4,900 KB
testcase_27 AC 2 ms
4,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n), r(n);
  for (auto&& e : a) cin >> e;
  for (auto&& e : r) cin >> e;
  vector<int> order(n);
  iota(begin(order), end(order), 0);
  sort(begin(order), end(order), [&](int i, int j) { return a[i] < a[j]; });
  vector<bool> marked(n);
  vector p(n, vector<double>(n + 1));
  for (int k = 1; k <= n; ++k) {
    marked[order[k - 1]] = true;
    vector<double> f{1};
    for (int i = 0; i < n; ++i) {
      if (marked[i]) f.insert(begin(f), 0);
      p[i][k] = accumulate(begin(f) + 1, end(f), double(0));
      vector<double> nf(size(f));
      for (int x = 0; x < int(size(f)); ++x) {
        nf[x] += f[x] / 2;
        nf[max(x - 1, 0)] += f[x] / 2;
      }
      f = move(nf);
    }
  }
  double ans = 0;
  for (int i = 0; i < n; ++i)
    for (int k = 1; k <= n; ++k) ans += (p[i][k] - p[i][k - 1]) * a[order[k - 1]] * r[i];
  ans /= 2;
  cout.precision(10);
  cout << ans << '\n';
}
0