結果

問題 No.1590 Random Shopping
ユーザー risujirohrisujiroh
提出日時 2021-07-08 23:52:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 158 ms / 5,000 ms
コード長 1,065 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 211,100 KB
実行使用メモリ 5,764 KB
最終ジャッジ日時 2023-09-14 05:44:34
合計ジャッジ時間 4,372 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,384 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 12 ms
4,376 KB
testcase_13 AC 42 ms
4,544 KB
testcase_14 AC 123 ms
5,764 KB
testcase_15 AC 124 ms
5,692 KB
testcase_16 AC 127 ms
5,720 KB
testcase_17 AC 123 ms
5,664 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 158 ms
5,660 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 91 ms
5,532 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 124 ms
5,604 KB
testcase_24 AC 121 ms
5,612 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 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